4

My solution compiles in VS2017 and VisualStudioVersion = 14.0.25420

Nuget restore fails in vsts build definition.Have performed below steps:

enter image description here

enter image description here enter image description here

I have referred below links and tried executing them, but still same error was thrown:

Using the latest NuGet in your build

Still no luck.

Detailed logs:

2018-03-16T08:30:20.9863624Z Task : NuGet 2018-03-16T08:30:20.9863815Z Description : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task. 2018-03-16T08:30:20.9863996Z Version : 2.0.24 2018-03-16T08:30:20.9864098Z Author : Microsoft Corporation 2018-03-16T08:30:20.9864232Z Help : More Information 2018-03-16T08:30:20.9864356Z ============================================================================== 2018-03-16T08:30:23.3611981Z Caching tool: NuGet 4.1.0 x64

2018-03-16T08:30:23.3717038Z Found tool in cache: NuGet 4.1.0 x64

2018-03-16T08:30:23.3790881Z Resolved from tool cache: 4.1.0

2018-03-16T08:30:23.3791208Z Using version: 4.1.0

2018-03-16T08:30:23.3794629Z Found tool in cache: NuGet 4.1.0 x64

2018-03-16T08:30:23.4907509Z [command]C:\Windows\system32\chcp.com 65001

2018-03-16T08:30:23.5489365Z Active code page: 65001

2018-03-16T08:30:23.5831075Z Detected NuGet version 4.1.0.2450 / 4.1.0

2018-03-16T08:30:23.5953230Z SYSTEMVSSCONNECTION exists true

2018-03-16T08:30:23.5976398Z Saving NuGet.config to a temporary config file.

2018-03-16T08:30:23.6021481Z [command]D:\a_tool\NuGet\4.1.0\x64\nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://api.nuget.org/v3/index.json -ConfigFile D:\a\1\Nuget\tempNuGet_13.config

2018-03-16T08:30:26.0565743Z Package Source with Name: NuGetOrg added successfully.

2018-03-16T08:30:26.0571052Z Saving NuGet.config to a temporary config file.

2018-03-16T08:30:26.0704297Z [command]D:\a_tool\NuGet\4.1.0\x64\nuget.exe restore D:\a\ts.sln -Verbosity Detailed -NonInteractive -ConfigFile D:\a\1\Nuget\tempNuGet_13.config

2018-03-16T08:30:29.9861727Z NuGet Version: 4.1.0.2450

2018-03-16T08:30:29.9862227Z MSBuild auto-detection: using msbuild version '15.6.82.30579' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.

2018-03-16T08:30:29.9863068Z System.AggregateException: One or more errors occurred. ---> NuGet.CommandLine.CommandLineException: Error parsing solution file at D:\a\ts.sln: Exception has been thrown by the target of an invocation.

2018-03-16T08:30:29.9868970Z at NuGet.CommandLine.MsBuildUtility.GetAllProjectFileNamesWithMsBuild(String solutionFile, String msbuildPath)

2018-03-16T08:30:29.9869367Z at NuGet.CommandLine.RestoreCommand.ProcessSolutionFile(String solutionFileFullPath, PackageRestoreInputs restoreInputs)

2018-03-16T08:30:29.9869611Z at NuGet.CommandLine.RestoreCommand.d__37.MoveNext()

2018-03-16T08:30:29.9869813Z --- End of stack trace from previous location where exception was thrown ---

2018-03-16T08:30:29.9869995Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

2018-03-16T08:30:29.9870166Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

2018-03-16T08:30:29.9870995Z at NuGet.CommandLine.RestoreCommand.d__30.MoveNext()

2018-03-16T08:30:29.9871164Z --- End of inner exception stack trace ---

2018-03-16T08:30:30.0446275Z ##[error]The nuget command failed with exit code(1) and error(System.AggregateException: One or more errors occurred. ---> NuGet.CommandLine.CommandLineException: Error parsing solution file at D:\a\ts.sln: Exception has been thrown by the target of an invocation. at NuGet.CommandLine.MsBuildUtility.GetAllProjectFileNamesWithMsBuild(String solutionFile, String msbuildPath) at NuGet.CommandLine.RestoreCommand.ProcessSolutionFile(String solutionFileFullPath, PackageRestoreInputs restoreInputs) at NuGet.CommandLine.RestoreCommand.d__37.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.d__30.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at NuGet.CommandLine.Command.Execute() at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args) ---> (Inner Exception #0) NuGet.CommandLine.CommandLineException: Error parsing solution file at D:\a\ts.sln: Exception has been thrown by the target of an invocation. at NuGet.CommandLine.MsBuildUtility.GetAllProjectFileNamesWithMsBuild(String solutionFile, String msbuildPath) at NuGet.CommandLine.RestoreCommand.ProcessSolutionFile(String solutionFileFullPath, PackageRestoreInputs restoreInputs) at NuGet.CommandLine.RestoreCommand.d__37.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.d__30.MoveNext()<---)

2018-03-16T08:30:30.0459326Z ##[error]Packages failed to restore

2018-03-16T08:30:30.0477190Z ##[section]Finishing: NuGet restore

Amruta
  • 701
  • 4
  • 15
  • 38
  • 1
    the configuration seems fine, looks like something with your sln-file is weird. The error message is cut off in the last screenshot but this looks like this issue -> https://stackoverflow.com/questions/36777583/msbuild-command-line-build-error-solution-file-error-msb5023-error-parsing-th – D.J. Mar 12 '18 at 14:06
  • It seems you are using Hosted VS2017 agent. If your project is developer in VS2015, please use the Hosted agent instead, and use nuget 3.5 instead. Or can you share your solution in one drive? – Marina Liu Mar 13 '18 at 06:14
  • @Marina - Yes, one of my project is created in VS2015 and it compiles error free in local. But when I use only nuget restore task with "Hosted" agent. Then I get error as "The nuget command failed with exit code(1) and error(Errors in packages.config projects Packages failed to restore" – Amruta Mar 16 '18 at 07:09
  • The above screenshots are for second project developed in VS 2017. I have used agent as "Hosted VS2017" and nuget task version "2". – Amruta Mar 16 '18 at 07:16
  • @Marina - My project compiles successfully in local. The same soln i have added to VSTS and just created a simple CI definition(with only Nuget task) – Amruta Mar 16 '18 at 07:47
  • @Amruta So can you show the detail logs from your VSTS build? – Marina Liu Mar 16 '18 at 07:52
  • @Marina - My VS2015 project build got successfully executed. But VS2017 project still having issues. I have added the detailed logs. – Amruta Mar 16 '18 at 08:41
  • @Amruta What's the agent do you use for that build, by Hosted agent? – Marina Liu Mar 16 '18 at 08:46
  • Agent - Hosted VS2017 – Amruta Mar 16 '18 at 08:51
  • Can not reproduce the issue. Can you share your solution (or an example solution failed with the same error) in one drive? – Marina Liu Mar 19 '18 at 09:27
  • As Mariana wrote, you are using vsts hosted agent, which builds using vs2017, with different targets configured then you have with vs2015. This can be your problem. Can you try to upgrade your solution to vs2017 and see if the error persists? I personally had issues with different versions of VS when building locally vs server – Rodrigo Werlang Mar 19 '18 at 21:15
  • Related - https://stackoverflow.com/questions/45100594/nuget-restore-exception-has-been-thrown-by-the-target-of-an-invocation/45100595#45100595 – sashoalm Sep 07 '21 at 12:34

1 Answers1

4

What helped me was the issue described in https://github.com/NuGet/Home/issues/6918 and the workaround described from AndrewGretton.

  1. Download and install the .NET 4.7.2 runtime (not SDK) from https://www.microsoft.com/net/download/dotnet-framework-runtime on the build agent
  2. Reboot the agent
  • 1
    This was the solution for us. This got us twice in a week though. I hope they fix the root cause soon. – Sam May 16 '18 at 19:32