Skip to content

Commit

Permalink
Handle when Resolve-Path throws if VS2019 is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmylewis committed Sep 23, 2019
1 parent fb69554 commit f9697fb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/common.lib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ function Locate-MSBuildPath($hasVsixExtension = "false") {
$vsInstallPath = Locate-VsInstallPath -hasVsixExtension $hasVsixExtension

# first try to find the VS2019+ path
$msbuildPath = Join-Path -path $vsInstallPath -childPath "MSBuild\Current\Bin"
$msbuildPath = Resolve-Path $msbuildPath

# otherwise fall back to the VS2017 path
if(!(Test-Path -path $msbuildPath)) {
try {
$msbuildPath = Join-Path -path $vsInstallPath -childPath "MSBuild\Current\Bin"
$msbuildPath = Resolve-Path $msbuildPath
}
catch {
# Resolve-Path throws if the path does not exist, so use the VS2017 path as a fallback
$msbuildPath = Join-Path -path $vsInstallPath -childPath "MSBuild\$msbuildVersion\Bin"
$msbuildPath = Resolve-Path $msbuildPath
}
Expand Down

0 comments on commit f9697fb

Please sign in to comment.