Skip to content

Commit

Permalink
chocolatey-visualstudio.extension: work around broken --update featur…
Browse files Browse the repository at this point in the history
…e of the bootstrapper

Due to the way the VS Installer update feature of the VS setup
bootstrapper (--update) is implemented, --update must be the last
argument, otherwise the bootstrapper will assume it is in "roundtrip
update" mode and will start the VS Installer once it is updated.

The problem is that recent versions of the parent ("box") application
(vs_<product>.exe) started appending an additional argument (--env) to
the VS setup bootstrapper invocation, effectively breaking the --update
feature. To add insult to injury, the --env argument is not used during
the VS installer update.

Fortunately, the box application is just a flavor of a self-extracting
zip archive and can be unzipped using standard zip tools. So, the
workaround is to unzip the box application and invoke the extracted VS
setup bootstrapper, taking care to pass arguments in correct order.

GitHub-Issue: GH-7 GH-8 GH-26
  • Loading branch information
jberezanski committed May 15, 2018
1 parent 5930380 commit a11787a
Showing 1 changed file with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,34 @@ function Install-VSInstaller
}
}

$boxExe = Get-VSWebFile `
-PackageName 'Visual Studio Installer' `
-DefaultFileName 'vs_setup.exe' `
-FileDescription 'installer executable' `
-Url $Url `
-Checksum $Checksum `
-ChecksumType $ChecksumType `
-LocalFilePath $installerFilePath

$chocTempDir = $env:TEMP
$tempDir = Join-Path $chocTempDir "$PackageName"
if ($env:packageVersion -ne $null) { $tempDir = Join-Path $tempDir "$env:packageVersion" }

$extractedBoxPath = Join-Path -Path $tempDir -ChildPath (Get-Item -Path $boxExe).BaseName
if (Test-Path -Path $extractedBoxPath)
{
Write-Debug "Removing already existing box extraction path: $extractedBoxPath"
Remove-Item -Path $extractedBoxPath -Recurse
}

Get-ChocolateyUnzip `
-PackageName 'Visual Studio Installer' `
-FileFullPath $boxExe `
-Destination $extractedBoxPath `
| Out-Null

$vsSetupBootstrapperExe = Join-Path -Resolve -Path $extractedBoxPath -ChildPath 'vs_bootstrapper_d15\vs_setup_bootstrapper.exe'

$whitelist = @('quiet', 'offline')
Remove-VSPackageParametersNotPassedToNativeInstaller -PackageParameters $PackageParameters -TargetDescription 'bootstrapper during VS Installer update' -Whitelist $whitelist

Expand All @@ -132,12 +160,9 @@ function Install-VSInstaller
$arguments = @{
packageName = 'Visual Studio Installer'
silentArgs = $silentArgs
url = $Url
checksum = $Checksum
checksumType = $ChecksumType
file = $vsSetupBootstrapperExe
logFilePath = $null
assumeNewVS2017Installer = $true
installerFilePath = $installerFilePath
}
$argumentsDump = ($arguments.GetEnumerator() | ForEach-Object { '-{0}:''{1}''' -f $_.Key,"$($_.Value)" }) -join ' '

Expand All @@ -146,8 +171,8 @@ function Install-VSInstaller
{
$retry = $false
$attempt += 1
Write-Debug "Install-VSChocolateyPackage $argumentsDump"
Install-VSChocolateyPackage @arguments
Write-Debug "Install-VSChocolateyInstallPackage $argumentsDump"
Install-VSChocolateyInstallPackage @arguments

$updated = Get-VisualStudioInstaller
if ($updated -eq $null)
Expand Down

0 comments on commit a11787a

Please sign in to comment.