Skip to content

Commit

Permalink
chocolatey-visualstudio.extension: do not use InstallChannelUri durin…
Browse files Browse the repository at this point in the history
…g product update

ChannelUri should be used for updates. InstallChannelUri can be used for
adding components/workloads.

GitHub-Issue: GH-7 GH-8 GH-10 GH-26
  • Loading branch information
jberezanski committed May 15, 2018
1 parent 71afa26 commit 110383e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ function Assert-VSInstallerUpdated
[PSObject] $ProductReference,
[string] $Url,
[string] $Checksum,
[string] $ChecksumType
[string] $ChecksumType,
[switch] $UseInstallChannelUri
)

$requiredVersionInfo = Get-VSRequiredInstallerVersion -PackageParameters $PackageParameters -ProductReference $productReference
$requiredVersionInfo = Get-VSRequiredInstallerVersion -PackageParameters $PackageParameters -ProductReference $productReference -UseInstallChannelUri:$UseInstallChannelUri
Install-VSInstaller `
-RequiredInstallerVersion $requiredVersionInfo.Version `
-RequiredEngineVersion $requiredVersionInfo.EngineVersion `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ function Get-VSBootstrapperUrlFromChannelManifest
Param
(
[Parameter(Mandatory = $true)] [hashtable] $PackageParameters,
[PSObject] $ProductReference
[PSObject] $ProductReference,
[switch] $UseInstallChannelUri
)
Write-Verbose 'Trying to determine the bootstrapper (vs_Setup.exe) url from the channel manifest'

Write-Debug 'Obtaining the channel manifest'
$manifest = Get-VSChannelManifest -PackageParameters $PackageParameters -ProductReference $ProductReference
$manifest = Get-VSChannelManifest -PackageParameters $PackageParameters -ProductReference $ProductReference -UseInstallChannelUri:$UseInstallChannelUri

Write-Debug 'Parsing the channel manifest'
$url, $checksum, $checksumType = Get-VSChannelManifestItemUrl -Manifest $manifest -ChannelItemType 'Bootstrapper'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ function Get-VSChannelManifest
Param
(
[Parameter(Mandatory = $true)] [hashtable] $PackageParameters,
[PSObject] $ProductReference
[PSObject] $ProductReference,
[switch] $UseInstallChannelUri
)

$manifestUri = $null
# first, see if the caller provided the manifest uri via package parameters or ProductReference
Write-Debug 'Checking if the channel manifest URI has been provided'
if ($PackageParameters.ContainsKey('installChannelUri') -and -not [string]::IsNullOrEmpty($PackageParameters['installChannelUri']))
Write-Debug ('InstallChannelUri will {0}' -f @{ $true = 'be used, if present'; $false = 'not be used' }[[bool]$UseInstallChannelUri])
if ($UseInstallChannelUri -and $PackageParameters.ContainsKey('installChannelUri') -and -not [string]::IsNullOrEmpty($PackageParameters['installChannelUri']))
{
$manifestUri = $PackageParameters['installChannelUri']
Write-Debug "Using channel manifest URI from the 'installChannelUri' package parameter: '$manifestUri'"
}
else
{
Write-Debug "Package parameters do not contain 'installChannelUri' or it is empty"
Write-Debug "Package parameters do not contain 'installChannelUri', it is empty or the scenario does not allow its use"
if ($PackageParameters.ContainsKey('channelUri') -and -not [string]::IsNullOrEmpty($PackageParameters['channelUri']))
{
$manifestUri = $PackageParameters['channelUri']
Expand All @@ -28,7 +30,7 @@ function Get-VSChannelManifest
Write-Debug "Package parameters do not contain 'channelUri' or it is empty"
if ($ProductReference -ne $null)
{
if (-not [string]::IsNullOrEmpty($ProductReference.InstallChannelUri))
if ($UseInstallChannelUri -and -not [string]::IsNullOrEmpty($ProductReference.InstallChannelUri))
{
$manifestUri = $ProductReference.InstallChannelUri
Write-Debug "Using manifest URI from the InstallChannelUri property of the provided ProductReference: '$manifestUri'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ function Get-VSComponentManifest
(
[Parameter(Mandatory = $true)] [hashtable] $PackageParameters,
[PSObject] $ProductReference,
[System.Collections.IDictionary] $ChannelManifest
[System.Collections.IDictionary] $ChannelManifest,
[switch] $UseInstallChannelUri
)

$layoutPath = Resolve-VSLayoutPath -PackageParameters $PackageParameters

if ($ChannelManifest -eq $null)
{
Write-Debug 'Obtaining the channel manifest'
$ChannelManifest = Get-VSChannelManifest -PackageParameters $PackageParameters -ProductReference $ProductReference -LayoutPath $layoutPath
$ChannelManifest = Get-VSChannelManifest -PackageParameters $PackageParameters -ProductReference $ProductReference -LayoutPath $layoutPath -UseInstallChannelUri:$UseInstallChannelUri
}

Write-Debug 'Parsing the channel manifest'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ function Get-VSRequiredInstallerVersion
Param
(
[Parameter(Mandatory = $true)] [hashtable] $PackageParameters,
[PSObject] $ProductReference
[PSObject] $ProductReference,
[switch] $UseInstallChannelUri
)
Write-Verbose 'Trying to determine the required installer and engine version from the manifests'

Write-Debug 'Obtaining the channel manifest in order to determine the required installer version'
$channelManifest = Get-VSChannelManifest -PackageParameters $PackageParameters -ProductReference $ProductReference
$channelManifest = Get-VSChannelManifest -PackageParameters $PackageParameters -ProductReference $ProductReference -UseInstallChannelUri:$UseInstallChannelUri

Write-Debug 'Parsing the channel manifest'
$version = $null
Expand Down Expand Up @@ -48,7 +49,7 @@ function Get-VSRequiredInstallerVersion
}

Write-Debug 'Obtaining the component manifest in order to determine the required engine version'
$manifest = Get-VSComponentManifest -PackageParameters $PackageParameters -ProductReference $ProductReference -ChannelManifest $channelManifest
$manifest = Get-VSComponentManifest -PackageParameters $PackageParameters -ProductReference $ProductReference -ChannelManifest $channelManifest -UseInstallChannelUri:$UseInstallChannelUri

Write-Debug 'Parsing the component manifest'
$engineVersion = $null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ function Install-VSInstaller
[string] $ChecksumType,
[Alias('RequiredVersion')] [version] $RequiredInstallerVersion,
[version] $RequiredEngineVersion,
[switch] $Force
[switch] $Force,
[switch] $UseInstallChannelUri
)
Write-Debug "Running 'Install-VSInstaller' for $PackageName with Url:'$Url' Checksum:$Checksum ChecksumType:$ChecksumType RequiredInstallerVersion:'$RequiredInstallerVersion' RequiredEngineVersion:'$RequiredEngineVersion' Force:'$Force'";
Write-Debug "Running 'Install-VSInstaller' for $PackageName with Url:'$Url' Checksum:$Checksum ChecksumType:$ChecksumType RequiredInstallerVersion:'$RequiredInstallerVersion' RequiredEngineVersion:'$RequiredEngineVersion' Force:'$Force' UseInstallChannelUri:'$UseInstallChannelUri'";

Write-Debug 'Determining whether the Visual Studio Installer needs to be installed/updated/reinstalled'
$shouldUpdate = $false
Expand Down Expand Up @@ -94,7 +95,7 @@ function Install-VSInstaller
$installerFilePath = $null
if ($Url -eq '')
{
$Url, $Checksum, $ChecksumType = Get-VSBootstrapperUrlFromChannelManifest -PackageParameters $PackageParameters -ProductReference $ProductReference
$Url, $Checksum, $ChecksumType = Get-VSBootstrapperUrlFromChannelManifest -PackageParameters $PackageParameters -ProductReference $ProductReference -UseInstallChannelUri:$UseInstallChannelUri
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@

if ($shouldFixInstaller -or ($Operation -ne 'uninstall' -and -not $installerUpdated))
{
$useInstallChannelUri = $Operation -ne 'update'
if ($PSCmdlet.ShouldProcess("Visual Studio Installer", "update"))
{
Assert-VSInstallerUpdated -PackageName $PackageName -PackageParameters $PackageParameters -ProductReference $thisProductReference -Url $BootstrapperUrl -Checksum $BootstrapperChecksum -ChecksumType $BootstrapperChecksumType
Assert-VSInstallerUpdated -PackageName $PackageName -PackageParameters $PackageParameters -ProductReference $thisProductReference -Url $BootstrapperUrl -Checksum $BootstrapperChecksum -ChecksumType $BootstrapperChecksumType -UseInstallChannelUri:$useInstallChannelUri
$installerUpdated = $true
$shouldFixInstaller = $false
$installer = Get-VisualStudioInstaller
Expand Down

0 comments on commit 110383e

Please sign in to comment.