Skip to content

Commit 3b6457d

Browse files
authored
Fallback to manually searching for tool dir (#1526)
1 parent 48f676e commit 3b6457d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/windows/find_tools.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,22 @@ mod impl_ {
815815
}
816816
}
817817
if version_file.is_empty() {
818-
return None;
818+
// If all else fails, manually search for bin directories.
819+
let tools_dir: PathBuf = dir.join(r"VC\Tools\MSVC");
820+
return tools_dir
821+
.read_dir()
822+
.ok()?
823+
.filter_map(|file| {
824+
let file = file.ok()?;
825+
let name = file.file_name().into_string().ok()?;
826+
827+
file.path().join("bin").exists().then(|| {
828+
let version = parse_version(&name);
829+
(name, version)
830+
})
831+
})
832+
.max_by(|(_, a), (_, b)| a.cmp(b))
833+
.map(|(version, _)| version);
819834
}
820835
version_path.push(version_file);
821836
File::open(version_path).ok()?

0 commit comments

Comments
 (0)