From b9b7eccf229a9ec23cd9b07c467b33845c05d78f Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Mon, 9 Aug 2021 17:18:43 -0500 Subject: [PATCH] Recalculate MSBuild path from VS Root A 64-bit application is now (after #6683) getting a good VS root path, but may still use toolsets from the wrong directory, because if it loaded (AnyCPU) assemblies from the 'x86' location it wouldn't pass a path containing md64 to the BuildEnvironment constructor, so the logic there wouldn't find the right MSBuildToolsDirectory and config file. Fix this in the lowest-impact way by rederiving the path to the 'correct' MSBuild.exe from the VS root and passing that to the BuildEnvironment constructor. --- src/Shared/BuildEnvironmentHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/BuildEnvironmentHelper.cs b/src/Shared/BuildEnvironmentHelper.cs index 6f739d163b8..f35dc2f8a6e 100644 --- a/src/Shared/BuildEnvironmentHelper.cs +++ b/src/Shared/BuildEnvironmentHelper.cs @@ -220,7 +220,7 @@ private static BuildEnvironment TryFromMSBuildExeUnderVisualStudio(string msbuil string visualStudioRoot = GetVsRootFromMSBuildAssembly(msbuildExe); return new BuildEnvironment( BuildEnvironmentMode.VisualStudio, - msbuildExe, + GetMSBuildExeFromVsRoot(visualStudioRoot), runningTests: s_runningTests(), runningInVisualStudio: false, visualStudioPath: visualStudioRoot);