Skip to content

Commit

Permalink
Ensure InstallVisualStudio.ps1 doesn't mix RTM and preview versions i…
Browse files Browse the repository at this point in the history
…f both are installed (#9260)
  • Loading branch information
natemcmaster authored Apr 10, 2019
1 parent 965eef4 commit fdca90b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions eng/scripts/InstallVisualStudio.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}

Expand All @@ -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`"", `
Expand Down

0 comments on commit fdca90b

Please sign in to comment.