Skip to content

Commit 030baed

Browse files
authored
Fixes #625 Support getting Windows SDK from the environment (#646)
1 parent 96c7e76 commit 030baed

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/windows_registry.rs

+8
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,15 @@ mod impl_ {
669669
// only need to bother checking x64, making this code a tiny bit simpler.
670670
// Like we do for the Universal CRT, we sort the possibilities
671671
// asciibetically to find the newest one as that is what vcvars does.
672+
// Before doing that, we check the "WindowsSdkDir" and "WindowsSDKVersion"
673+
// environment variables set by vcvars to use the environment sdk version
674+
// if one is already configured.
672675
fn get_sdk10_dir() -> Option<(PathBuf, String)> {
676+
if let (Ok(root), Ok(version)) = (env::var("WindowsSdkDir"), env::var("WindowsSDKVersion"))
677+
{
678+
return Some((root.into(), version.trim_end_matches('\\').to_string()));
679+
}
680+
673681
let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0";
674682
let key = LOCAL_MACHINE.open(key.as_ref()).ok()?;
675683
let root = key.query_str("InstallationFolder").ok()?;

0 commit comments

Comments
 (0)