File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments