Azure-pipelines-tasks: Nuget restore fails on latest vsImage = Windows-2019

Created on 8 Apr 2020  路  2Comments  路  Source: microsoft/azure-pipelines-tasks

Required Information

Question, Bug, or Feature?
Type: Bug

Enter Task Name: NuGetCommand@2

Environment

Azure Pipelines
Agent - Hosted

Issue Description

In yaml pipeline file, when vmImage: 'windows-2019' or vmImage: 'windows-latest', NuGet restore fails with following error:

2020-04-06T17:33:51.5632607Z NuGet Version: 4.4.1.4656
2020-04-06T17:33:51.5633538Z MSBuild auto-detection: using msbuild version '16.5.0.12403' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
2020-04-06T17:33:51.5631558Z Error parsing solution file at D:\a\1\s\project.sln: Exception has been thrown by the target of an invocation.  The project file could not be loaded. Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.  D:\a\1\s\project.sln
2020-04-06T17:33:51.5632607Z NuGet Version: 4.4.1.4656
2020-04-06T17:33:51.5633538Z MSBuild auto-detection: using msbuild version '16.5.0.12403' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
2020-04-06T17:33:51.5635023Z NuGet.CommandLine.CommandLineException: Error parsing solution file at D:\a\1\s\project.sln: Exception has been thrown by the target of an invocation.  The project file could not be loaded. Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.  D:\a\1\s\360DegreeView.sln
2020-04-06T17:33:51.5636277Z    at NuGet.CommandLine.MsBuildUtility.GetAllProjectFileNamesWithMsBuild(String solutionFile, String msbuildPath)
2020-04-06T17:33:51.5636873Z    at NuGet.CommandLine.RestoreCommand.ProcessSolutionFile(String solutionFileFullPath, PackageRestoreInputs restoreInputs)
2020-04-06T17:33:51.5637476Z    at NuGet.CommandLine.RestoreCommand.<DetermineRestoreInputsAsync>d__42.MoveNext()
2020-04-06T17:33:51.5637941Z --- End of stack trace from previous location where exception was thrown ---

Issue is specific to Windows 2019 image. NuGet restore works successfully when vmImage: 'vs2017-win2016'.

Everything was working fine for windows-2019 image five hours earlier on 2020-04-06T12:39:43.6352039Z.

The difference seems to be the msbuild version. In exception above, msbuild version is 16.5.0.12403. In the previous run that was successful, it is msbuild version 16.4.0.56107.

This shows the msbuild version on the previous run:

2020-04-06T12:39:45.6232029Z [command]C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe restore D:\a\1\s\360DegreeView.sln -Verbosity Detailed -NonInteractive
2020-04-06T12:40:25.2005949Z NuGet Version: 4.4.1.4656
2020-04-06T12:40:25.2006810Z MSBuild auto-detection: using msbuild version '16.4.0.56107' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
2020-04-06T12:40:25.2007733Z MSBuild P2P timeout [ms]: 120000
2020-04-06T12:40:25.2008936Z C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin\msbuild.exe "C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\wjfgwk2u.jd1.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\o1xkb2oj.hca.nugetrestore.targets" /p:RestoreTaskAssemblyFile="C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe" /p:RestoreSolutionDirectory="D:\a\1\s" /p:SolutionDir="D:\a\1\s"
2020-04-06T12:40:25.2010110Z 

Task logs

Can be provided upon request

Troubleshooting

Can be done upon request

Error logs

Can be provided upon request

Artifacts bug

All 2 comments

Hi @pnwguy ,

To get these errors to stop, please add the Nuget Tool Installer task (docs here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/nuget?view=azure-devops) before running the restore to update the nuget version that the task is using. Please use the latest version of nuget.

Additionally, please make sure to kick off a new run of the job - this will pull down the latest version of the task as there are fixes in there. Re-running a job will use the same task as it used initially.

Please let me know if this unblocks you.

Thanks, I already had that, but didn't realize how old the version I had. Once I removed versionSpec parameter completely, it chose a later version and it worked successfully. Closing.

Was this page helpful?
0 / 5 - 0 ratings