NuGet / Home

Repo for NuGet Client issues

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IOException during restore not very informative

rainersigwald opened this issue · comments

NuGet Product Used

dotnet.exe, MSBuild.exe

Product Version

.NET SDK 9.0.100-preview.5.24307.3

Worked before?

Not sure, this is the first time I've seen the exception.

Impact

It bothers me. A fix would be nice

Repro Steps & Context

I'm not sure what caused the underlying error but I had a build failure that manifested as

  sdk failed with 1 error(s) (3.0s)
    S:\sdk\.dotnet\sdk\9.0.100-preview.5.24307.3\NuGet.targets(170,5): error : Cannot create a file when that file already exists.

Build failed with 1 error(s) in 31.7s

Which wasn't super helpful! I had a binlog attached which showed this stack:

System.IO.IOException: Cannot create a file when that file already exists.
   at System.IO.FileSystem.MoveFile(String sourceFullPath, String destFullPath, Boolean overwrite)
   at NuGet.Common.FileUtility.Move(String sourceFileName, String destFileName)
   at NuGet.Common.FileUtility.Replace(String sourceFileName, String destFileName)
   at NuGet.Common.FileUtility.Replace(Action`1 writeSourceFile, String destFilePath)
   at NuGet.Common.FileUtility.Replace(Action`1 writeSourceFile, String destFilePath)
   at NuGet.Commands.BuildAssetsUtils.WriteFiles(IEnumerable`1 files, ILogger log)
   at NuGet.Commands.RestoreResult.CommitAssetsFileAsync(LockFileFormat lockFileFormat, ILogger log, Boolean toolCommit, CancellationToken token)
   at NuGet.Commands.RestoreResult.CommitAsync(ILogger log, CancellationToken token)
   at NuGet.Commands.RestoreRunner.CommitAsync(RestoreResultPair restoreResult, IRestoreProgressReporter progressReporter, CancellationToken token)
   at NuGet.Commands.RestoreRunner.ExecuteAndCommitAsync(RestoreSummaryRequest summaryRequest, IRestoreProgressReporter progressReporter, CancellationToken token)
   at NuGet.Commands.RestoreRunner.CompleteTaskAsync(List`1 restoreTasks)
   at NuGet.Commands.RestoreRunner.RunAsync(IEnumerable`1 restoreRequests, RestoreArgs restoreArgs, CancellationToken token)
   at NuGet.Commands.RestoreRunner.RunAsync(RestoreArgs restoreContext, CancellationToken token)
   at NuGet.Build.Tasks.BuildTasksUtility.RestoreAsync(DependencyGraphSpec dependencyGraphSpec, Boolean interactive, Boolean recursive, Boolean noCache, Boolean ignoreFailedSources, Boolean disableParallel, Boolean force, Boolean forceEvaluate, Boolean hideWarningsAndErrors, Boolean restorePC, Boolean cleanupAssetsForUnsupportedProjects, ILogger log, CancellationToken cancellationToken)
   at NuGet.Build.Tasks.RestoreTask.ExecuteAsync(ILogger log)

Ideally the file being created would be called out by path, and the NuGet error would have more context about what NuGet was doing when this happened.

Verbose Logs

No response

Appears to be a duplicate of #7648