Ensure InstallVisualStudio.ps1 doesn't mix RTM and preview versions if both are installed (#9260)
This commit is contained in:
parent
965eef4a57
commit
fdca90b7f6
|
|
@ -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`"", `
|
||||
|
|
|
|||
Loading…
Reference in New Issue