Build issue in devops pipeline with nuget restore latest version

Viewed 1675

When I try to run the build pipeline from Azure DevOps, I am getting an error with NuGet restore task for the latest version. It is not happening every time. After multiple attempts, the pipeline is getting successfully executed.

NuGet.CommandLine.ExitCodeException: Exception of type 'NuGet.CommandLine.ExitCodeException' was thrown.
   at NuGet.CommandLine.MsBuildUtility.<GetProjectReferencesAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.RestoreCommand.<GetDependencyGraphSpecAsync>d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.CommandLine.RestoreCommand.<DetermineInputsFromMSBuildAsync>d__63.MoveNext()
2 Answers

Build issue in devops pipeline with nuget restore latest version

This is a known issue about the nuget from the version 4.8.1, and this issue has not been solved in the version (5.4).

NuGet experts replied:

I'd imagine this is a fall out from the perf work with SkipNonExistentTargets.

The issue here is that these projects likely have non-existing imports. Projects like take a toll on the msbuild evaluation and make it significantly slower.

Try setting RestoreUseSkipNonexistentTargets="false"

To resolve this issue, we could use the NuGet tool installer task to install the old version nuget like: 4.7.1. Or we could try to set the property RestoreUseSkipNonexistentTargets="false" in a Directory.Build.Props at the root of your repo.

Please check the open issue 7796 on github for some more details.

Hope this helps.

Building a solution will hide the real error message. Try building each project separately so that you can get the error message and fix it.

Related