Mono: Improve MSBuildFinder logic on Windows

Support detecting both 32-bit and 64-bit installations of `vswhere.exe`.
This commit is contained in:
Thaina Yu 2020-08-19 23:20:53 +07:00 committed by Rémi Verschelde
parent 7d6c5c90b5
commit 5dc3900727
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 15 additions and 2 deletions

View File

@ -161,8 +161,21 @@ namespace GodotTools.Build
// Try to find 15.0 with vswhere // Try to find 15.0 with vswhere
string vsWherePath = Environment.GetEnvironmentVariable(Internal.GodotIs32Bits() ? "ProgramFiles" : "ProgramFiles(x86)"); var envNames = Internal.GodotIs32Bits() ? new[] { "ProgramFiles", "ProgramW6432" } : new[] { "ProgramFiles(x86)", "ProgramFiles" };
string vsWherePath = null;
foreach (var envName in envNames)
{
vsWherePath = Environment.GetEnvironmentVariable(envName);
if (!string.IsNullOrEmpty(vsWherePath))
{
vsWherePath += "\\Microsoft Visual Studio\\Installer\\vswhere.exe"; vsWherePath += "\\Microsoft Visual Studio\\Installer\\vswhere.exe";
if (File.Exists(vsWherePath))
break;
}
vsWherePath = null;
}
var vsWhereArgs = new[] {"-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild"}; var vsWhereArgs = new[] {"-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild"};