Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.IO.DirectoryNotFoundException: Could not find a part of the path during Restore #9844

Closed
japj opened this issue Jul 27, 2020 · 4 comments
Labels
Functionality:Restore Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Bug

Comments

@japj
Copy link

japj commented Jul 27, 2020

Details about Problem

NuGet product used: MSBuild restore

VS version : VS2019 16.5.5

OS version: Windows Server 2016 1607 (14393.3750)

Worked before? Possibly, using VS2019 16.4.0

The restore is running as part of a Build Definition in a build step (Azure DevOps Server/on premise agent).
The System.IO.DirectoryNotFoundException error seems to occur (more) frequently after having recently updated to VS2019 16.5.5 (it is not entirely clear if this also occurred with VS2019 16.4.0, but that is what we were using before)

Unfortunately it is not 100% reproducable.

#7341 and #7908 seem to describe similar occurrences of this issue (but then it only seemed to happen on linux/mac machines?). We have a similar issue, but specifically on Windows machines.

NuGet/NuGet.Client#2774 also mentions that this problem occurrence might be related to the amount of projects being restored in the solution, but reproducing it also seemed to be difficult there.

Detailed repro steps so we can see the same problem

  1. a solution with 218 projects in it (C++ vcxproj, C# csproj (.NET Framework) and some dotnet core projects), plus several projects using the Microsoft.Build.NoTargets Sdk and a company private MSBuild Sdk.

  2. run MSBuild /t:restore on the solution

Verbose Logs

##[error]someprojectfile.csproj(7,5): Error : System.AggregateException: One or more errors occurred. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\agent04\_work\_temp\mspdbsrv.17a37a44-6da2-4803-b51c-3e2225fc04f2\NuGetScratch\cfbbb4d423d44644b09f91277a2ef8be\adc573783fc0444ba0738b1f95891d13.proj.nuget.dgspec.json'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at NuGet.ProjectModel.DependencyGraphSpec.Save(String path)
   at NuGet.Commands.NoOpRestoreUtilities.PersistDGSpecFile(DependencyGraphSpec spec, String dgPath, ILogger log)
   at NuGet.Commands.RestoreCommand.EvaluateCacheFile()
   at NuGet.Commands.RestoreCommand.<ExecuteAsync>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<ExecuteAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<CompleteTaskAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<RunWithoutCommit>d__3.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Microsoft.Build.NuGetSdkResolver.NuGetSdkResolver.NuGetAbstraction.GetSdkResult(SdkReference sdk, Object nuGetVersion, SdkResolverContext context, SdkResultFactory factory)
---> (Inner Exception #0) System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\agent04\_work\_temp\mspdbsrv.17a37a44-6da2-4803-b51c-3e2225fc04f2\NuGetScratch\cfbbb4d423d44644b09f91277a2ef8be\adc573783fc0444ba0738b1f95891d13.proj.nuget.dgspec.json'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at NuGet.ProjectModel.DependencyGraphSpec.Save(String path)
   at NuGet.Commands.NoOpRestoreUtilities.PersistDGSpecFile(DependencyGraphSpec spec, String dgPath, ILogger log)
   at NuGet.Commands.RestoreCommand.EvaluateCacheFile()
   at NuGet.Commands.RestoreCommand.<ExecuteAsync>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<ExecuteAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<CompleteTaskAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.Commands.RestoreRunner.<RunWithoutCommit>d__3.MoveNext()<---
@zkat zkat added Functionality:Restore Category:Quality Week Issues that should be considered for quality week Priority:2 Issues for the current backlog. RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Tenet:Performance Performance issues Type:Bug labels Jul 28, 2020
@aortiz-msft aortiz-msft removed Category:Quality Week Issues that should be considered for quality week Tenet:Performance Performance issues labels Jul 29, 2020
@zkat zkat added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. and removed Priority:2 Issues for the current backlog. RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 labels Aug 6, 2020
@japj
Copy link
Author

japj commented Sep 15, 2020

Do you need more information to analyze this?
We are still getting this on our CI systems on occasion.

@jeffkl
Copy link
Contributor

jeffkl commented Sep 22, 2020

Based on the stack trace, this was probably fixed by NuGet/NuGet.Client#3261 because the method that's failing (NoOpRestoreUtilities.PersistDGSpecFile) doesn't exist any more. Are you able to use the latest Visual Studio 2019 16.7.2 and see if it still happens?

@japj
Copy link
Author

japj commented Sep 23, 2020

@jeffkl thanks, great to hear this problem should be solved with 16.7.2. I will bump the priority of testing internal rollout of 16.7.2 so we can confirm it solves the issue

@japj
Copy link
Author

japj commented May 22, 2021

I can confirm we have not seen this issue for a while now

@japj japj closed this as completed May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Restore Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Bug
Projects
None yet
Development

No branches or pull requests

5 participants