Home: NuGet CLI does not work with MSBuild 15.0 on Windows

Created on 19 Nov 2016  路  15Comments  路  Source: NuGet/Home

Details about Problem

Nuget.exe does not work with only Visual Studio 2017 RC installed.

NuGet product used = NuGet.exe
NuGet Version: 4.0.0.2089
VS version: 2017 RC
OS version: Windows 10.0.14393

Detailed repro steps so we can see the same problem

  1. Install Visual Studio 2017 RC on a system without an installation of previous version of Visual Studio or MSBuild.

  2. Run Nuget.exe restore...

C:\a\w\1\s>tools\nuget\NuGet.exe restore
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.

Most helpful comment

Please use -MsbuildPath, for example
C:\a\w\1\s>tools\nuget\NuGet.exe restore -MsbuildPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"

All 15 comments

Please use -MsbuildPath, for example
C:\a\w\1\s>tools\nuget\NuGet.exe restore -MsbuildPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"

related, but with different versions of msbuild and nuget: #4091

This now works as expected (with 4.0.0.2275). Thanks!

Is there a solution for when using this on a build server? Or do we need to install VS 2015?

NuGet.exe v3.5 requires msbuild 14 on the machine. Sorry.
NuGet.exe v4.0 should not have that problem, and also properly works with VS 2017's msbuild (which is now no longer installed machine wide).
@RyanDawkins - does that solve it for you?

I'm having the same problem where it cannot find any of the packages.

I have NuGet.exe v4.0 and I'm using VS2017. My problem seems very similar to https://github.com/NuGet/Home/issues/4091

@rrelyea

@RyanDawkins Could you explain your problem more? what's the scenario (restore?pack?) and how you use nuget.exe? Did you use "MsbuildPath" or "MsbuildVersion"? what's the error message?

If you just want to restore with VS 2017, "nuget.exe restore" should works well.

I am running nuget.exe on a build server and running restore. My server only has msbuild version 12 installed.

@zhili1208

what's the error message? you mentioned "I'm having the same problem where it cannot find any of the packages", your issue is "nuget can't load msbuild" or "can't find packages"? and what's your nuget build number?

For those still having issues on a build server -- you need to install the .net targeting/dev packs

Also note that nuget pack -MSBuildPath will require you to update to v4. Its available in v3, but only for restore

Its also broken in that it does not recognize its been given the path to MsBuild.exe, and not just the folder that contains the exe.
image

-MSBuildPath is only in v4, and "it does not recognize the path to Msbuild.exe" tracking in https://github.com/NuGet/Home/issues/4195. In nuget v4.3, there is no need to use MsbuildPath, nuget can find msbuild 15 automatically.

I know its not fun dealing with CLI and large choices of args, but nuget update -self doesnt give me v4.3. Any idea when thats going to be out?

@StingyJack
Use following command:

nuget update -Self -Prerelease

The version is not marked as stable.
https://dist.nuget.org/index.html

@StingyJack - if things go as planned, 4.3.0 will be released sometime in August 2017.

Was this page helpful?
0 / 5 - 0 ratings