11

NuGet apparently has some logic to determine what MSBuild Executable to use. Is there a way to override this behavior? Or at least a way to tell it to use the x86 MSBuild instead of x64?

MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin\amd64'.

2 Answers 2

17

From the command-line documentation, you can specify -MSBuildPath or -MSBuildVersion on the command line.

MSBuildPath (4.0+) Specifies the path of MSBuild to use with the command, taking precedence over -MSBuildVersion.

MSBuildVersion (3.2+) Specifies the version of MSBuild to be used with this command. Supported values are 4, 12, 14, 15. By default the MSBuild in your path is picked, otherwise it defaults to the highest installed version of MSBuild.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you @Rainer Sigwald; not sure how I missed the documentation. Helped me fix this issue with the latest Xamarin Installer stackoverflow.com/questions/45350208/…
But this command-line option only affects current command, it will not change the default msbuild detection. I can't add this option every time when I'm trying to restore a solution.
1

The msbuild version used by nuget command line on mono is hard coded:

Cf source code https://github.com/NuGet/NuGet.Client/blob/f24bad0668193ce21a1db8cabd1ce95ba509c7f0/src/NuGet.Clients/NuGet.CommandLine/MsBuildUtility.cs

The offending method is GetMsBuildFromMonoPaths(...)

There is no env var to override it. It's called "auto detection" lol.

A solution is to move away the /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/15.0 folder, install msbuild 16.0 using dotnet-install.sh method (use version 5.0.402 for msbuild 16), and create a symbolic link from dotnet/sdk/$netcoreversion to the hard coded path /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/15.0

4 Comments

Might be worth opening an issue with NuGet they are usually pretty responsive?
@aolszowka well on this one they are not. The issue is already open.
can you link the GitHub issue?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.