Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuget.exe does not work with msbuild 12 as of 3.5.0 [fixed in 4.0.0] #4091

Closed
rliberoff opened this issue Dec 12, 2016 · 16 comments
Closed

nuget.exe does not work with msbuild 12 as of 3.5.0 [fixed in 4.0.0] #4091

rliberoff opened this issue Dec 12, 2016 · 16 comments
Assignees
Labels
Priority:2 Issues for the current backlog. Product:NuGet.exe NuGet.exe RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Triage:Investigate Type:Bug
Milestone

Comments

@rliberoff
Copy link

We are downloading the latest version of the NuGet CLI from this URL "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" which is configured in the NuGet.targets file to always download it when doing a build in TFS 2013.

When executing the "nuget.exe pack" the following error happens:

**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.**

The TFS reports the following invocation (some info removed due to NDA):

C:>"C:\Builds\5......\src\NuGet.exe"
pack "C:\Builds\5......\src......vbproj" -IncludeReferencedProjects -Properties "Configuration=Release;Platform=AnyCPU;OutputPath=C:\Builds\5......\bin"
-NonInteractive -OutputDirectory "C:\Builds\5......\bin" -symbols -MsBuildVersion 12 -Version 7.0.6190.34419

The NuGet CLI version is 3.5.0.1938

Could someone please help us?

@rrelyea
Copy link
Contributor

rrelyea commented Dec 13, 2016

It looks like your command line is looking for msbuild version 12, but the error complains that you are loading v14.
Did this work with a previous version of NuGet.exe? Which one?
Or have other things changed too?

@rrelyea rrelyea added the Viewed label Dec 13, 2016
@rliberoff
Copy link
Author

Hi Rob,

Thanks for your prompt answer.

Before NuGet CLI version 3.5.0.1938, We were using the NuGet CLI version 3.4.4.1321.

When using version 3.4.4.1321 everything works flawlessly. If We switch to version 3.5.0.1938 then the mentioned error is reported.

We though that adding the "-MsBuildVersion 12" parameter with version 3.5.0.1938 would solve the issue, but clearly that didn't worked.

We really appreciate your help.

Regards,

@rrelyea rrelyea added this to the 4.0 RC3 milestone Dec 13, 2016
@rrelyea rrelyea added the Priority:2 Issues for the current backlog. label Dec 13, 2016
@rrelyea
Copy link
Contributor

rrelyea commented Dec 13, 2016

@zhili1208 - would be great to understand workaround...and also understand if there is a bug that we should be fixing.

zhili1208 added a commit to NuGet/NuGet.Client that referenced this issue Dec 13, 2016
@rrelyea
Copy link
Contributor

rrelyea commented Dec 14, 2016

We did some work in NuGet 3.5.0 to deal with the major changes in VS 2017, which includes support for side by side install of VS and msbuild. No MsBuild is in the gac anymore.

Workaround - install Msbuild v14 on your machine. This will allow NuGet 3.5.0 to find msbuild v12 well.
(I think this is the right place to do that from: https://www.microsoft.com/en-us/download/details.aspx?id=48159)

Our current plan is to fix this in NuGet 4.0, please let us know if this workaround isn't feasible until that is available.

@agbrown-bp
Copy link

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.

...

Before NuGet CLI version 3.5.0.1938, We were using the NuGet CLI version 3.4.4.1321.
When using version 3.4.4.1321 everything works flawlessly. If We switch to version 3.5.0.1938 then the mentioned error is reported.

+1 on this exact error message. Except we aren't doing anything with TFS and we hit it for the nuget.exe restore command.

For us this happens on a machine with only VS2013 installed, which runs msbuild v12 from the command line via batch script for a build. Part of the batch script pulls nuget.exe from https://dist.nuget.org/win-x86-commandline/latest/nuget.exe. Once it started automatically pulling 3.5.0.1938 instead of 3.4.4.1321 we hit this breaking change.

I would prefer not to install Msbuild v14.0 as a workaround as I don't know what else that will break for our build processes. Our CI servers use MsBuild 12.0 as well so it isn't just a case of changing things on one machine.

@agbrown-bp
Copy link

@rliberoff Would you be happy to edit the title of this issue to the more general "nuget.exe does not work with msbuild 12 as of 3.5.0"? I think it better reflects the actual issue which we now know is not specific to TFS 2013.

@zhili1208 zhili1208 changed the title TFS 2013 BUILD fails when using latest version of NuGet CLI nuget.exe does not work with msbuild 12 as of 3.5.0 Dec 27, 2016
zhili1208 added a commit to NuGet/NuGet.Client that referenced this issue Dec 27, 2016
@rrelyea rrelyea changed the title nuget.exe does not work with msbuild 12 as of 3.5.0 nuget.exe does not work with msbuild 12 as of 3.5.0 [fixed in 4.0.0] Aug 16, 2017
@rrelyea rrelyea added the RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 label Aug 16, 2017
@o7g8
Copy link

o7g8 commented Aug 22, 2017

I still experience the issue with NuGet Version: 4.3.0.4406 and NuGet Version: 4.1.0.2450.
I use Windows 10 and have VS2013 and VS2015 installed on it.

The automatic detection works fine:

> nuget.exe restore XXX.sln
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin\amd64'

If I specify explicit msbuild versions, I get errors:

> nuget.exe restore  -MsBuildVersion 14 XXX.sln
Cannot find the specified version of msbuild: '14'
> nuget.exe restore  -MsBuildVersion 12 XXX.sln
Cannot find the specified version of msbuild: '12'

@zhili1208
Copy link
Contributor

could you share the 14 and 12 msbuild full version number on your machine?
"msbuild.exe /ver" to get full version number

@o7g8
Copy link

o7g8 commented Aug 23, 2017

@zhili1208 here are the full versions:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64>msbuild /ver
Microsoft (R) Build Engine version 12.0.40629.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

12.0.40629.0
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>msbuild /ver
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.

14.0.25420.1

@zhili1208
Copy link
Contributor

@o7g8 Please clone my repo https://github.com/zhili1208/NuGetMsbuildChecker, build it and run "NuGetMsbuildChecker.exe 14", it will print all msbuild information. Thanks

@o7g8
Copy link

o7g8 commented Aug 24, 2017

@zhili1208 thank you for you answer! Here is the output from the tool:

>.\NuGetMsbuildChecker.exe 14
Fetching all msbuild toolsets
Installed toolsets count: 3
toolset version: 12.0, toolset path: C:\Program Files (x86)\MSBuild\12.0\bin
toolset version: 14.0, toolset path: C:\Program Files (x86)\MSBuild\14.0\bin
toolset version: 4.0, toolset path: C:\Windows\Microsoft.NET\Framework\v4.0.30319
Can't find msbuild toolset
userVersionString: 14,0
toolset version: 12.0, toolset path: C:\Program Files (x86)\MSBuild\12.0\bin
toolset version: 14.0, toolset path: C:\Program Files (x86)\MSBuild\14.0\bin
toolset version: 4.0, toolset path: C:\Windows\Microsoft.NET\Framework\v4.0.30319

Can it be an issue with processing of . and ,?

@zhili1208
Copy link
Contributor

@o7g8 looks like there is an issue with parsing the version string

@zhili1208 zhili1208 reopened this Aug 24, 2017
@zhili1208
Copy link
Contributor

zhili1208 commented Aug 24, 2017

@o7g8 I think the issue is parsing version string dosen't use InvariantCulture, I fixed it in my NuGetMsbuildChecker, could you pull it and try it again? thanks

@o7g8
Copy link

o7g8 commented Aug 25, 2017

@zhili1208 thank you! now it works :)

>.\NuGetMsbuildChecker.exe 12
Fetching all msbuild toolsets
Installed toolsets count: 5
toolset version: 12.0, toolset path: C:\Program Files (x86)\MSBuild\12.0\bin
toolset version: 14.0, toolset path: C:\Program Files (x86)\MSBuild\14.0\bin
toolset version: 2.0, toolset path: C:\Windows\Microsoft.NET\Framework\v2.0.50727
toolset version: 3.5, toolset path: C:\Windows\Microsoft.NET\Framework\v3.5
toolset version: 4.0, toolset path: C:\Windows\Microsoft.NET\Framework\v4.0.30319
Found msbuild toolset
toolset version: 12.0, toolset path: C:\Program Files (x86)\MSBuild\12.0\bin

and for 14 as well:

>.\NuGetMsbuildChecker.exe 14
Fetching all msbuild toolsets
Installed toolsets count: 5
toolset version: 12.0, toolset path: C:\Program Files (x86)\MSBuild\12.0\bin
toolset version: 14.0, toolset path: C:\Program Files (x86)\MSBuild\14.0\bin
toolset version: 2.0, toolset path: C:\Windows\Microsoft.NET\Framework\v2.0.50727
toolset version: 3.5, toolset path: C:\Windows\Microsoft.NET\Framework\v3.5
toolset version: 4.0, toolset path: C:\Windows\Microsoft.NET\Framework\v4.0.30319
Found msbuild toolset
toolset version: 14.0, toolset path: C:\Program Files (x86)\MSBuild\14.0\bin

@zhili1208
Copy link
Contributor

Great, I will fix this in product

@zhili1208
Copy link
Contributor

Fixed in NuGet/NuGet.Client@e7bf7fe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:2 Issues for the current backlog. Product:NuGet.exe NuGet.exe RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Triage:Investigate Type:Bug
Projects
None yet
Development

No branches or pull requests

5 participants