throw"Developer Command Prompt for VS $(${env:VSCMD_VER}) is not recent enough. Please upgrade to {$vsMinimumVersion} or build from a normal CMD window"
}
}
# Look for a valid VS installation
try{
$p=Get-VisualStudioDir
$p=Join-Path$p"MSBuild\15.0\Bin"
Write-Output"vsinstall"
Write-Output$p
return
}
catch{
# Failures are expected here when no VS installation is present on the
# machine.
}
Write-Output"xcopy"
Write-Output(Get-MSBuildDirXCopy)
return
}
# Locate the xcopy version of MSBuild
functionGet-MSBuildDirXCopy(){
$p=Ensure-BasicTool"RoslynTools.MSBuild"
$p=Join-Path$p"tools\MSBuild\15.0\Bin"
return$p
}
functionGet-MSBuildDir([switch]$xcopy=$false){
$both=Get-MSBuildKindAndDir-xcopy:$xcopy
return$both[1]
}
# Dose this version of Visual Studio meet our minimum requirements for building.
# Report error - the developer environment is initialized with incompatible VS version.
throw"Developer Command Prompt for VS $($env:VisualStudioVersion) is not recent enough. Please upgrade to $vsMinVersionStr or build from a plain CMD window"
}
}
# Locate Visual Studio installation or download x-copy msbuild.