2017-01-23 12:54:03 -08:00
|
|
|
[CmdletBinding()]
|
|
|
|
param(
|
2017-02-12 22:18:09 -08:00
|
|
|
[Parameter(Mandatory=$False)]
|
2017-11-09 21:41:16 -08:00
|
|
|
[string]$withVSPath = ""
|
2017-01-23 12:54:03 -08:00
|
|
|
)
|
|
|
|
|
2017-11-09 21:41:16 -08:00
|
|
|
$withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash
|
2017-02-24 16:11:48 -08:00
|
|
|
|
2018-01-22 18:18:53 -08:00
|
|
|
$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
|
2017-10-05 18:25:34 -07:00
|
|
|
$VisualStudioInstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1
|
2017-11-30 16:43:41 -08:00
|
|
|
if ($VisualStudioInstallationInstances -eq $null)
|
|
|
|
{
|
|
|
|
throw "Could not find Visual Studio. VS2015 or VS2017 (with C++) needs to be installed."
|
|
|
|
}
|
|
|
|
|
2017-10-05 18:25:34 -07:00
|
|
|
Write-Verbose "VS Candidates:`n`r$([system.String]::Join([Environment]::NewLine, $VisualStudioInstallationInstances))"
|
2017-10-19 19:50:23 -07:00
|
|
|
foreach ($instanceCandidateWithEOL in $VisualStudioInstallationInstances)
|
2017-01-23 12:54:03 -08:00
|
|
|
{
|
2017-10-31 17:06:07 -07:00
|
|
|
$instanceCandidate = $instanceCandidateWithEOL -replace "<sol>::" -replace "::<eol>"
|
2017-10-05 18:25:34 -07:00
|
|
|
Write-Verbose "Inspecting: $instanceCandidate"
|
|
|
|
$split = $instanceCandidate -split "::"
|
|
|
|
# $preferenceWeight = $split[0]
|
|
|
|
# $releaseType = $split[1]
|
|
|
|
$version = $split[2]
|
|
|
|
$path = $split[3]
|
2017-02-24 16:11:48 -08:00
|
|
|
|
2017-11-09 21:41:16 -08:00
|
|
|
if ($withVSPath -ne "" -and $withVSPath -ne $path)
|
2017-02-24 16:11:48 -08:00
|
|
|
{
|
2017-10-05 18:25:34 -07:00
|
|
|
Write-Verbose "Skipping: $instanceCandidate"
|
2017-02-24 16:11:48 -08:00
|
|
|
continue
|
2017-01-23 12:54:03 -08:00
|
|
|
}
|
2017-02-24 16:11:48 -08:00
|
|
|
|
2017-10-05 18:25:34 -07:00
|
|
|
$majorVersion = $version.Substring(0,2);
|
|
|
|
if ($majorVersion -eq "15")
|
2017-02-24 16:11:48 -08:00
|
|
|
{
|
2017-10-05 18:25:34 -07: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-24 16:11:48 -08:00
|
|
|
}
|
|
|
|
|
2017-10-05 18:25:34 -07:00
|
|
|
if ($majorVersion -eq "14")
|
2017-02-24 16:11:48 -08:00
|
|
|
{
|
2017-10-05 18:25:34 -07:00
|
|
|
$clExe= "$path\VC\bin\cl.exe"
|
|
|
|
if (Test-Path $clExe)
|
|
|
|
{
|
|
|
|
Write-Verbose "Picking: $instanceCandidate"
|
2017-10-05 22:44:49 -07:00
|
|
|
$programFilesPath = & $scriptsDir\getProgramFiles32bit.ps1
|
2017-10-05 18:25:34 -07:00
|
|
|
return "$programFilesPath\MSBuild\14.0\Bin\MSBuild.exe", "v140"
|
|
|
|
}
|
2017-02-24 16:11:48 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 22:18:09 -08:00
|
|
|
throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed."
|