瀏覽代碼

Mono: Improve MSBuildFinder logic on Windows

Support detecting both 32-bit and 64-bit installations of `vswhere.exe`.
Thaina Yu 5 年之前
父節點
當前提交
5dc3900727
共有 1 個文件被更改,包括 15 次插入2 次删除
  1. 15 2
      modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs

+ 15 - 2
modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs

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