Skip to content
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

fix msbuild from vs2022 not being found #773

Merged
merged 1 commit into from
Jan 26, 2023

Conversation

seritools
Copy link
Contributor

@seritools seritools commented Jan 24, 2023

Without this (and only VS 2022 installed), find_tool with msbuild returns C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe instead of the MSBuild.exe from the actual VS installation.

In other words:

cc::windows_registry::find_tool("x86_64-pc-windows-msvc", "msbuild.exe").unwrap().path()

returns C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe instead of something like C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe, as find_msbuild is missing the check for VS17.

Copy link
Contributor

@ChrisDenton ChrisDenton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@ChrisDenton ChrisDenton merged commit f507481 into rust-lang:main Jan 26, 2023
@seritools seritools deleted the fix-msbuild-vs17-search branch January 26, 2023 14:57
@malkia
Copy link

malkia commented Mar 18, 2023

The issue above mentions VS2022, yet the change has vs17 in it.

Also VS2022 is no longer installed in "C:\Program Files (x86)" (by default), but in "C:\Program Files"

@ChrisDenton
Copy link
Contributor

The VS2017 method uses COM to find the installation, which will work for later VS versions too. It will return whatever the path is, be it in Program Files (x86), Program Files or elsewhere. You can test this yourself. E.g.:

fn main() {
    let tool = cc::windows_registry::find_tool("x86_64-pc-windows-msvc", "msbuild.exe").unwrap();
    println!("{}", tool.path().display());
}

If you find there's still a problem, then please create a new issue with details so it can be investigated.

@seritools
Copy link
Contributor Author

@malkia Visual Studio 2022 has the version number 17.

@malkia
Copy link

malkia commented Mar 20, 2023

oh right, feel dumb now :) It's just that I was thinking about the Visual Studio 2017 and got it mixed up! Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants