2017-01-24 04:54:03 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
param(
|
2017-02-13 14:18:09 +08:00
|
|
|
[Parameter(Mandatory=$False)]
|
2017-11-10 13:41:16 +08:00
|
|
|
[string]$withVSPath = ""
|
2017-01-24 04:54:03 +08:00
|
|
|
)
|
|
|
|
|
2017-11-10 13:41:16 +08:00
|
|
|
$withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash
|
2017-02-25 08:11:48 +08:00
|
|
|
|
2018-01-23 10:18:53 +08:00
|
|
|
$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
|
2017-10-06 09:25:34 +08:00
|
|
|
$VisualStudioInstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1
|
2017-12-01 08: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-06 09:25:34 +08:00
|
|
|
Write-Verbose "VS Candidates:`n`r$([system.String]::Join([Environment]::NewLine, $VisualStudioInstallationInstances))"
|
2017-10-20 10:50:23 +08:00
|
|
|
foreach ($instanceCandidateWithEOL in $VisualStudioInstallationInstances)
|
2017-01-24 04:54:03 +08:00
|
|
|
{
|
2017-11-01 08:06:07 +08:00
|
|
|
$instanceCandidate = $instanceCandidateWithEOL -replace "<sol>::" -replace "::<eol>"
|
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-11-10 13:41:16 +08:00
|
|
|
if ($withVSPath -ne "" -and $withVSPath -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."
|