Home: MSBuildVersion 15 not supported

Created on 5 May 2017  路  5Comments  路  Source: NuGet/Home

Please read the following information before posting the issue.

Before posting the issue...

  • If you're having trouble with the NuGet.org Website, please post in NuGetGallery issues
  • If you're having trouble with the NuGet client tools (the Visual Studio extension, NuGet.exe command line tool, etc.), you are in the right place.

Remove the content above here and fill out details below.

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):
nuget.exe

NuGet version (x.x.x.xxx):
3.5.0.1996

dotnet.exe --version (if appropriate):
1.0.3

VS version (if appropriate):
2017

OS version (i.e. win10 v1607 (14393.321)):
10.15063.138

Worked before? If so, with which NuGet version:
n/a

Detailed repro steps so we can see the same problem

  1. Create a new C# project in VS 2017.
  2. Use one of the new C# 7 language features (implicit decl, pattern matching, etc)
  3. Attempt nuget pack
  4. Observe failure
  5. Attempt to specify MSBuildVersion 15
  6. Observe "can't find" error

Other suggested things

Verbose Logs

C:\Users\...\Projects\Personal\...>nuget pack ....csproj -build -properties configuration=release -verbosity detailed *-msbuildversion 15*
NuGet Version: 3.5.0.1996
Attempting to build package from '....csproj'.
NuGet.CommandLine.CommandLineException: Failed to load msbuild Toolset --->
>>> NuGet.CommandLine.CommandLineException: Cannot find the specified version of msbuild: '15'
   at NuGet.CommandLine.MsBuildUtility.GetMsbuildDirectoryInternal(String userVersion, IConsole console, IEnumerable`1 installedToolsets)
   at NuGet.CommandLine.MsBuildUtility.GetMsbuildDirectory(String userVersion, IConsole console)
   --- End of inner exception stack trace ---
   at NuGet.CommandLine.MsBuildUtility.GetMsbuildDirectory(String userVersion, IConsole console)
   at NuGet.CommandLine.PackCommand.<ExecuteCommand>b__64_0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
   at NuGet.Commands.PackCommandRunner.BuildPackage(String path)
   at NuGet.Commands.PackCommandRunner.BuildPackage()
   at NuGet.CommandLine.PackCommand.ExecuteCommand()
   at NuGet.CommandLine.Command.ExecuteCommandAsync()
   at NuGet.CommandLine.Command.Execute()
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)

C:\Users\...\Projects\Personal\...>dir "c:\Program Files (x86)\MSBuild"
 Volume in drive C is OSDisk
 Volume Serial Number is 82E0-F9F6

 Directory of c:\Program Files (x86)\MSBuild

03/24/2017  10:51 AM    <DIR>          .
03/24/2017  10:51 AM    <DIR>          ..
07/13/2016  12:52 PM    <DIR>          12.0
07/13/2016  07:16 PM    <DIR>          14.0
>>> 03/07/2017  10:28 AM    <DIR>          15.0
07/13/2016  05:57 PM    <DIR>          4.0
03/24/2017  10:51 AM    <DIR>          Microsoft
07/13/2016  12:48 PM    <DIR>          Microsoft.Cpp
02/23/2017  09:18 PM    <DIR>          Novell
02/23/2017  09:18 PM    <DIR>          Xamarin
               0 File(s)              0 bytes
              10 Dir(s)  142,212,685,824 bytes free
NuGet.exe Investigate NeedsTriageDiscussion Bug

All 5 comments

Please use nuget.exe 4.1 from https://dist.nuget.org/index.html and specify MSBuildVersion 15.1, because actually msbuild version is 15.1 for VS 2017, so specifying 15 can't find msbuild

Dealing with this issue since yesterday. I actually had to uninstall previous MSBuid versions on my build server and remove the -MSBuildVersion argument from the call to get it to work with 15.1.

I cannot get this to work even if I specify 15.1 as the -MSBuildVersion.

P.S.: The agent is specified as "VS 2017". The NuGet version is specified as 4.0.0. I tried using 4.1.0 but no luck so far. There is no documentation regarding how to use "NuGet Tools Installer" task.

C:\LR\mms\Services\Mms\Provisioner\TaskAgent\agents\2.117.1\externals\nuget\NuGet.exe pack "d:\a\1\s\Src\ProjectName\ProjectName.csproj" -OutputDirectory "d:\a\1\a\Packages" -Properties Configuration=release -version 1.0.20170616 -MSBuildVersion 15.1
Cannot find the specified version of msbuild: '15.1'
System.Exception: Unexpected exit code 1 returned from tool NuGet.exe
   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
PowerShell script completed with 1 errors.

The same exception is thrown if I specify MSBuildVersion as "15" instead of "15.1".

NuGet 3.5 didn't find v15, I've downloaded latest NuGet 4.3 and had to remove -MSBuildVersion (attempts to specify 15, 15.0 or 15.1 didn't help).
Then the MS Build was found:

MSBuild auto-detection: using msbuild version '15.3.409.57025' 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.

The last sentence is wrong/misleading. I confirmed that only -MSBuildVersion 15.3 is acceptable value on my machine.

Was this page helpful?
0 / 5 - 0 ratings