-
-
Save alan-null/a6b19038c386c8c9dcd9c62496383a08 to your computer and use it in GitHub Desktop.
PowerShell to resolve MSBuild.exe on VS2017 or VS2015 (or with Build Tools 2015)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Resolve-MsBuild { | |
$msb2017 = Resolve-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\*\*\MSBuild\*\bin\msbuild.exe" -ErrorAction SilentlyContinue | |
if($msb2017) { | |
Write-Host "Found MSBuild 2017 (or later)." | |
Write-Host $msb2017 | |
return $msb2017 | Select-Object -First 1 | |
} | |
$msBuild2015 = "${env:ProgramFiles(x86)}\MSBuild\14.0\bin\msbuild.exe" | |
if(-not (Test-Path $msBuild2015)) { | |
throw 'Could not find MSBuild 2015 or later.' | |
} | |
Write-Host "Found MSBuild 2015." | |
Write-Host $msBuild2015 | |
return $msBuild2015 | |
} | |
$msBuild = Resolve-MsBuild | |
# e.g. & $msBuild .\Foo.sln |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment