Skip to content

Commit c2aa0d3

Browse files
committed
msvc: allow finding tools from path if VisualStudioDir is set
1 parent ee14401 commit c2aa0d3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/windows/find_tools.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,20 @@ mod impl_ {
361361
target: TargetArch<'_>,
362362
env_getter: &dyn EnvGetter,
363363
) -> Option<Tool> {
364-
// Early return if the environment doesn't contain a VC install.
365-
env_getter.get_env("VCINSTALLDIR")?;
366-
let vs_install_dir: PathBuf = env_getter.get_env("VSINSTALLDIR")?.into();
364+
// Early return if the environment isn't one that is known to have compiler toolsets in PATH
365+
// `VCINSTALLDIR` is set from vcvarsall.bat (developer command prompt)
366+
// `VisualStudioDir` is set by msbuild when invoking custom build steps
367+
if env_getter.get_env("VCINSTALLDIR").is_none()
368+
&& env_getter.get_env("VisualStudioDir").is_none()
369+
{
370+
return None;
371+
}
367372

368373
// If the vscmd target differs from the requested target then
369374
// attempt to get the tool using the VS install directory.
370375
if is_vscmd_target(target, env_getter) == Some(false) {
371376
// We will only get here with versions 15+.
377+
let vs_install_dir: PathBuf = env_getter.get_env("VSINSTALLDIR")?.into();
372378
tool_from_vs15plus_instance(tool, target, &vs_install_dir, env_getter)
373379
} else {
374380
// Fallback to simply using the current environment.

0 commit comments

Comments
 (0)