powershell - How to find whether a certain file is available in the system path? -
my powershell script must run vs command prompt, , want verity checking msbuild.exe in path. managed using where.exe:
where.exe msbuild.exe > $null if ($lastexitcode -ne 0) { throw "buildall must run ""developer command prompt vs2012"" shortcut." } however, doesn't feel "the powershell way" - there powershell-native way this?
try if msbuild.exe must in same folder script is
if ( test-path (join-path (split-path -parent $myinvocation.mycommand.definition) "msbuild.exe " )) { ... } else { ... } if want check if build.exe available command (any available path $env:path) can do:
if ([bool](get-command "msbuild.exe" -ea silentlycontinue)) { ... }
Comments
Post a Comment