microsoft / MSBuildLocator

An API to locate MSBuild assemblies from an installed Visual Studio location. Use this to ensure that calling the MSBuild API will use the same toolset that a build from Visual Studio or msbuild.exe would.
Other
216 stars 83 forks source link

64-bit MSBuild.exe is not used when custom process is 64-bit #133

Open jeffkl opened 3 years ago

jeffkl commented 3 years ago

If you create a custom application that is AnyCPU but prefer 32-bit is set to false, then MSBuild locator will register the 32-bit MSBuild. This breaks out-of-proc builds with an error like this:

Build was canceled. Failed to successfully launch or connect to a child MSBuild.exe process. 
Verify that the MSBuild.exe "C:\Program Files (x86)\Visual Studio 2019 Preview\MSBuild\Current\Bin\MSBuild.exe"
 launches successfully, and that it is loading the same microsoft.build.dll that the launching process loaded.
 If the location seems incorrect, try specifying the correct location in the BuildParameters object, or with
 the MSBUILD_EXE_PATH environment variable.

This is because the handshake between the 64-bit application and the 32-bit MSBuild.exe doesn't match up. MSBuildLocator should use the 64-bit MSBuild.exe if Environment.Is64BitProcess is true