2017-01-24 04:54:03 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
param(
|
2017-02-13 14:18:09 +08:00
|
|
|
[Parameter(Mandatory=$False)]
|
2017-10-06 09:25:34 +08:00
|
|
|
[string]$explicitlyRequestedVSPath = ""
|
2017-01-24 04:54:03 +08:00
|
|
|
)
|
|
|
|
|
2017-10-06 09:25:34 +08:00
|
|
|
$explicitlyRequestedVSPath = $explicitlyRequestedVSPath -replace "\\$" # Remove potential trailing backslash
|
2017-02-25 08:11:48 +08:00
|
|
|
|
2017-01-24 04:54:03 +08:00
|
|
|
$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition
|
2017-10-06 09:25:34 +08:00
|
|
|
$VisualStudioInstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1
|
|
|
|
Write-Verbose "VS Candidates:`n`r$([system.String]::Join([Environment]::NewLine, $VisualStudioInstallationInstances))"
|
|
|
|
foreach ($instanceCandidate in $VisualStudioInstallationInstances)
|
2017-01-24 04:54:03 +08:00
|
|
|
{
|
2017-10-06 09:25:34 +08:00
|
|
|
Write-Verbose "Inspecting: $instanceCandidate"
|
|
|
|
$split = $instanceCandidate -split "::"
|
|
|
|
# $preferenceWeight = $split[0]
|
|
|
|
# $releaseType = $split[1]
|
|
|
|
$version = $split[2]
|
|
|
|
$path = $split[3]
|
2017-02-25 08:11:48 +08:00
|
|
|
|
2017-10-06 09:25:34 +08:00
|
|
|
if ($explicitlyRequestedVSPath -ne "" -and $explicitlyRequestedVSPath -ne $path)
|
2017-02-25 08:11:48 +08:00
|
|
|
{
|
2017-10-06 09:25:34 +08:00
|
|
|
Write-Verbose "Skipping: $instanceCandidate"
|
2017-02-25 08:11:48 +08:00
|
|
|
continue
|
2017-01-24 04:54:03 +08:00
|
|
|
}
|
2017-02-25 08:11:48 +08:00
|
|
|
|
2017-10-06 09:25:34 +08:00
|
|
|
$majorVersion = $version.Substring(0,2);
|
|
|
|
if ($majorVersion -eq "15")
|
2017-02-25 08:11:48 +08:00
|
|
|
{
|
2017-10-06 09:25:34 +08:00
|
|
|
$VCFolder= "$path\VC\Tools\MSVC\"
|
|
|
|
if (Test-Path $VCFolder)
|
|
|
|
{
|
|
|
|
Write-Verbose "Picking: $instanceCandidate"
|
|
|
|
return "$path\MSBuild\15.0\Bin\MSBuild.exe", "v141"
|
|
|
|
}
|
2017-02-25 08:11:48 +08:00
|
|
|
}
|
|
|
|
|
2017-10-06 09:25:34 +08:00
|
|
|
if ($majorVersion -eq "14")
|
2017-02-25 08:11:48 +08:00
|
|
|
{
|
2017-10-06 09:25:34 +08:00
|
|
|
$clExe= "$path\VC\bin\cl.exe"
|
|
|
|
if (Test-Path $clExe)
|
|
|
|
{
|
|
|
|
Write-Verbose "Picking: $instanceCandidate"
|
2017-10-06 13:44:49 +08:00
|
|
|
$programFilesPath = & $scriptsDir\getProgramFiles32bit.ps1
|
2017-10-06 09:25:34 +08:00
|
|
|
return "$programFilesPath\MSBuild\14.0\Bin\MSBuild.exe", "v140"
|
|
|
|
}
|
2017-02-25 08:11:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-13 14:18:09 +08:00
|
|
|
throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed."
|