Azure-pipelines-tasks: Nuget 3.5 @ TF2017.1 - missing Microsoft.Build, Version=14.0 while version VS2017 (15) is installed

Created on 4 Jan 2017  路  14Comments  路  Source: microsoft/azure-pipelines-tasks

TF2017 with local agent and Visual Studio 2017RC (Version 15) installed.

I changed my Nuget Restore build task from Nuget Version 3.3 to 3.5 and receive this error:

2016-12-30T13:44:08.9114291Z NuGet Version: 3.5.0.1938 2016-12-30T13:44:09.0207999Z System.AggregateException: One or more errors occurred. ---> NuGet.CommandLine.CommandLineException: Failed to load msbuild Toolset ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. 2016-12-30T13:44:09.0207999Z at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 2016-12-30T13:44:09.0207999Z at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 2016-12-30T13:44:09.0207999Z at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 2016-12-30T13:44:09.0207999Z at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) 2016-12-30T13:44:09.0207999Z at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 2016-12-30T13:44:09.0207999Z at System.Reflection.Assembly.Load(String assemblyString) 2016-12-30T13:44:09.0207999Z at NuGet.CommandLine.MsBuildUtility.GetMsbuildDirectory(String userVersion, IConsole console)

It seems that there is a hard dependency on VS2015 ?

Most helpful comment

All 14 comments

Facing the same error with nuget using in Teamcity.

I'm getting the same error building a NuGet Packager solution in Visual Studio 2013. I just updated the NuGet Package Manager extension for VS 2013.

Even running this from the command line:

C:\Path\To\MyProject>.\NuGet.exe pack MyProject.csproj

Ends with the same error.

I downloaded NuGet.exe version 4.0.0-RC4 and it fixed the issue: https://dist.nuget.org/

I have the same problem on a newly installed build server with Visual Studio 2017

TFS2017 Update 1 - issue still exist - Nuget Installer 0.2.29


Starting: NuGet restore ***.sln


Task : NuGet Installer
Description : Installs or restores missing NuGet packages
Version : 0.2.29
Author : Microsoft Corporation
Help : More Information


C:\Windows\system32\chcp.com 65001
Active code page: 65001
Detected NuGet version 3.5.0.1938 / 3.5.0
SYSTEMVSSCONNECTION exists true
C:\TfsBuildAgents_work_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe restore -NonInteractive C:\TfsBuildAgents_work\1\s\XXXXXXX.sln -Verbosity Normal
Failed to load msbuild Toolset
Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Error: C:\TfsBuildAgents_work_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe failed with return code: 1
Packages failed to install

I experienced this error using VSTS with an on premise build agent (not using TFS 2017). Things work fine as long as I choose 3.3, but I get this error when I choose nuget 3.5 in the task.
Our build agent ONLY has VS2017 installed.

Experiencing this error on VS2017 hosted agent in VSTS too. When using 3.3 things work fine as brettjacobson noticed too. Maybe an error relating to the image.

_2017-03-25T07:50:06.7076029Z [command]C:\a_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe restore -NonInteractive C:\a\1\s\Clients.sln
2017-03-25T07:50:07.4507062Z Failed to load msbuild Toolset
2017-03-25T07:50:07.4507062Z Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2017-03-25T07:50:07.4577057Z ##[debug]rc:1
2017-03-25T07:50:07.4577057Z ##[debug]success:false_

Same here with TFS 2017.1 and NuGet 3.5

Same here. I reproduced this with the following steps:

  • Created a new solution (.sln) file
  • Created a new c# web project on .net 4.6.2 (not .net core), selected Empty as the template and included mvc and web api libraries
  • Persisted this to TFS
  • Created a new build from the template with only 2 steps

    • Get sources

    • NuGet restore

The Detailed output from NuGet is this

2017-04-05T16:57:34.9053640Z ##[section]Starting: NuGet restore **\*.sln
2017-04-05T16:57:34.9153685Z ==============================================================================
2017-04-05T16:57:34.9153685Z Task         : NuGet Installer
2017-04-05T16:57:34.9153685Z Description  : Installs or restores missing NuGet packages
2017-04-05T16:57:34.9153685Z Version      : 0.2.29
2017-04-05T16:57:34.9153685Z Author       : Microsoft Corporation
2017-04-05T16:57:34.9153685Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2017-04-05T16:57:34.9153685Z ==============================================================================
2017-04-05T16:57:36.1653406Z [command]C:\Windows\system32\chcp.com 65001
2017-04-05T16:57:36.1963363Z Active code page: 65001
2017-04-05T16:57:36.2483403Z Detected NuGet version 3.5.0.1938 / 3.5.0
2017-04-05T16:57:36.2523459Z SYSTEMVSSCONNECTION exists true
2017-04-05T16:57:36.2553400Z [command]C:\a\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe restore -NonInteractive C:\a\1\s\TestData\_TestBuild.sln -Verbosity Detailed
2017-04-05T16:57:37.0820631Z NuGet Version: 3.5.0.1938
2017-04-05T16:57:37.2891893Z System.AggregateException: One or more errors occurred. ---> NuGet.CommandLine.CommandLineException: Failed to load msbuild Toolset ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
2017-04-05T16:57:37.2901945Z    at System.Reflection.Assembly.Load(String assemblyString)
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.MsBuildUtility.GetMsbuildDirectory(String userVersion, IConsole console)
2017-04-05T16:57:37.2901945Z    --- End of inner exception stack trace ---
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.MsBuildUtility.GetMsbuildDirectory(String userVersion, IConsole console)
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.RestoreCommand.<ExecuteCommandAsync>b__22_0()
2017-04-05T16:57:37.2901945Z    at System.Lazy`1.CreateValue()
2017-04-05T16:57:37.2901945Z    at System.Lazy`1.LazyInitValue()
2017-04-05T16:57:37.2901945Z    at System.Lazy`1.get_Value()
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.RestoreCommand.ProcessSolutionFile(String solutionFileFullPath, PackageRestoreInputs restoreInputs)
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.RestoreCommand.GetInputsFromFile(String projectFilePath, PackageRestoreInputs packageRestoreInputs)
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.RestoreCommand.DetermineRestoreInputs()
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.RestoreCommand.<ExecuteCommandAsync>d__22.MoveNext()
2017-04-05T16:57:37.2901945Z    --- End of inner exception stack trace ---
2017-04-05T16:57:37.2901945Z    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
2017-04-05T16:57:37.2901945Z    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.Command.Execute()
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
2017-04-05T16:57:37.2901945Z ---> (Inner Exception #0) NuGet.CommandLine.CommandLineException: Failed to load msbuild Toolset ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
2017-04-05T16:57:37.2901945Z    at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
2017-04-05T16:57:37.2901945Z    at System.Reflection.Assembly.Load(String assemblyString)
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.MsBuildUtility.GetMsbuildDirectory(String userVersion, IConsole console)
2017-04-05T16:57:37.2901945Z    --- End of inner exception stack trace ---
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.MsBuildUtility.GetMsbuildDirectory(String userVersion, IConsole console)
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.RestoreCommand.<ExecuteCommandAsync>b__22_0()
2017-04-05T16:57:37.2901945Z    at System.Lazy`1.CreateValue()
2017-04-05T16:57:37.2901945Z    at System.Lazy`1.LazyInitValue()
2017-04-05T16:57:37.2901945Z    at System.Lazy`1.get_Value()
2017-04-05T16:57:37.2901945Z    at NuGet.CommandLine.RestoreCommand.ProcessSolutionFile(String solutionFileFullPath, PackageRestoreInputs restoreInputs)
2017-04-05T16:57:37.2912195Z    at NuGet.CommandLine.RestoreCommand.GetInputsFromFile(String projectFilePath, PackageRestoreInputs packageRestoreInputs)
2017-04-05T16:57:37.2912195Z    at NuGet.CommandLine.RestoreCommand.DetermineRestoreInputs()
2017-04-05T16:57:37.2912195Z    at NuGet.CommandLine.RestoreCommand.<ExecuteCommandAsync>d__22.MoveNext()<---
2017-04-05T16:57:37.2912195Z 
2017-04-05T16:57:37.3244660Z ##[error]Error: C:\a\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe failed with return code: 1
2017-04-05T16:57:37.3254658Z ##[error]Packages failed to install
2017-04-05T16:57:37.3284651Z ##[section]Finishing: NuGet restore **\*.sln

The same issues seems to be occurring in VSTS as well, when using
NuGet 3.5: http://stackoverflow.com/questions/43287078/xamarin-uwp-vsts-nuget-package-restore-fails

Same problem here.

There's a dependency between NuGet >=3.5 and Visual Studio 2015, and NuGet >=4.0 and Visual Studio 2017.

We've updated the NuGet Installer task to have a new radio button for NuGet 4.0. Selecting that should fix this issue.

And this is what it looks like in VSTS:

nuget

How do I get this update on my local TFS server?

Was this page helpful?
0 / 5 - 0 ratings