-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mono: Improve MSBuildFinder logic on Windows #41375
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,8 +161,21 @@ private static string FindMsBuildToolsPathOnWindows() | |
|
||
// 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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not directly about this PR's changes, but can we just use |
||
if (File.Exists(vsWherePath)) | ||
break; | ||
} | ||
|
||
vsWherePath = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if this is reached? What's the result of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same as passing an empty string. OS.execute may print an error. Albeit to be fair the old code didn't check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will there be any possible chance that someone would install their vs installer outside of ProgramFiles and just directly in the drive though? |
||
} | ||
|
||
var vsWhereArgs = new[] {"-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild"}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to check the matching architecture's path first? This would mean that the
"ProgramFiles"
environment variable is checked first, since for a 32-bit process it points to 32-bit Program Files, and for a 64-bit process it points to 64-bit Program Files.We might be able to optimize this further by only changing the fallback environment variable. I haven't compiled this but I wonder if this works:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I have heard is, in windows 64 bit, Visual Studio Installer most likely be installed in
ProgramFiles(x86)
by default. Only me or some people that change the default path of installer would met this problem. So I think it would be more efficient to ordering this wayThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm just thinking of future proofing it, in case there is a 64-bit Visual Studio Installer in the future and then it would be placed in the 64-bit folder instead (and if both exist, 64-bit Godot would prefer the 64-bit one). I'll let @neikeq decide what's best here.