4
votes

We are using Nuget Installer step that restores the missing nuget packages in TFS build, this step fails with the following error:

E:\Builds\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe restore -NonInteractive E:\Builds\test.sln MSBuild auto-detection: using msbuild version '3.5' from 'C:\Windows\Microsoft.NET\Framework\v3.5'. Error parsing solution file at E:\Builds\test.sln: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) Error: E:\Builds\Agent2017Update1_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe failed with return code: 1 Packages failed to install

The error message seems to be confusing as the file specified is present on build agent.

TFS build agent version:2.112.0 TFS version: TFS 2017 update 1

2

2 Answers

1
votes

This seems to be due to the fact that the msbuild.exe in your path (your build agent) is version 3.5. MSBuild 3.5 does not have two .dll's that nuget are attempting to load dynamically (Microsoft.Build.dll and Microsoft.Build.Framework.dll).

A solution to fix this issue, please make sure NuGet.exe uses MSBuild 4.0 or higher. This can be done by making sure MSBuild 4.0 or higher is the first to resolve in your path or by passing the -msbuildversion option. For example, use MSBuild 14.0 (which shipped with Visual Studio 2015).

nuget.exe pack MyProj.csproj -msbuildversion 14.0

More details please refer this similar issue nuget pack fails when MSBuild version resolved to MSBuild 3.5

3
votes

In the Advanced options change the version to 3.5 for NuGet. I've been having weird issues the last 2 weeks where 3.3 would do similar to what you are experiencing and switching to 3.5 works as expected.

enter image description here

Hope this works for you as well =D