Ensure InstallVisualStudio.ps1 doesn't mix RTM and preview versions if both are installed (#9260)

This commit is contained in:
Nate McMaster 2019-04-10 14:55:58 -07:00 committed by GitHub
parent 965eef4a57
commit fdca90b7f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 6 deletions

View File

@ -50,12 +50,26 @@ $bootstrapper = "$intermedateDir\vsinstaller.exe"
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
Invoke-WebRequest -Uri "https://aka.ms/vs/16/release/vs_$($Edition.ToLowerInvariant()).exe" -OutFile $bootstrapper
$responseFile = "$PSScriptRoot\vs.json"
if ("$Edition" -eq "BuildTools") {
$responseFile = "$PSScriptRoot\vs.buildtools.json"
}
$channelId = (Get-Content $responseFile | ConvertFrom-Json).channelId
$productId = "Microsoft.VisualStudio.Product.$Edition"
if (-not $InstallPath) {
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vsWhere)
{
$InstallPath = &$vsWhere -version '[16,17)' -latest -prerelease -products $productId -property installationPath
$installations = & $vsWhere -version '[16,17)' -format json -sort -prerelease -products $productId | ConvertFrom-Json
foreach ($installation in $installations) {
Write-Host "Found '$($installation.installationName)' in '$($installation.installationPath)', channel = '$($installation.channelId)'"
if ($installation.channelId -eq $channelId) {
$InstallPath = $installation.installationPath
break
}
}
}
}
@ -71,11 +85,6 @@ if (Test-path $InstallPath) {
$arguments += 'modify'
}
$responseFile = "$PSScriptRoot\vs.json"
if ("$Edition" -eq "BuildTools") {
$responseFile = "$PSScriptRoot\vs.buildtools.json"
}
$arguments += `
'--productId', $productId, `
'--installPath', "`"$InstallPath`"", `