diff --git a/chocolatey-visualstudio.extension/extensions/Assert-VSInstallerUpdated.ps1 b/chocolatey-visualstudio.extension/extensions/Assert-VSInstallerUpdated.ps1 index ad7fcd1a..7ec436ba 100644 --- a/chocolatey-visualstudio.extension/extensions/Assert-VSInstallerUpdated.ps1 +++ b/chocolatey-visualstudio.extension/extensions/Assert-VSInstallerUpdated.ps1 @@ -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 ` diff --git a/chocolatey-visualstudio.extension/extensions/Get-VSBootstrapperUrlFromChannelManifest.ps1 b/chocolatey-visualstudio.extension/extensions/Get-VSBootstrapperUrlFromChannelManifest.ps1 index 8db86fbb..8f57ed99 100644 --- a/chocolatey-visualstudio.extension/extensions/Get-VSBootstrapperUrlFromChannelManifest.ps1 +++ b/chocolatey-visualstudio.extension/extensions/Get-VSBootstrapperUrlFromChannelManifest.ps1 @@ -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' diff --git a/chocolatey-visualstudio.extension/extensions/Get-VSChannelManifest.ps1 b/chocolatey-visualstudio.extension/extensions/Get-VSChannelManifest.ps1 index 0427319a..4d4fe76c 100644 --- a/chocolatey-visualstudio.extension/extensions/Get-VSChannelManifest.ps1 +++ b/chocolatey-visualstudio.extension/extensions/Get-VSChannelManifest.ps1 @@ -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'] @@ -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'" diff --git a/chocolatey-visualstudio.extension/extensions/Get-VSComponentManifest.ps1 b/chocolatey-visualstudio.extension/extensions/Get-VSComponentManifest.ps1 index 9865c431..26ef469f 100644 --- a/chocolatey-visualstudio.extension/extensions/Get-VSComponentManifest.ps1 +++ b/chocolatey-visualstudio.extension/extensions/Get-VSComponentManifest.ps1 @@ -5,7 +5,8 @@ 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 @@ -13,7 +14,7 @@ function Get-VSComponentManifest 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' diff --git a/chocolatey-visualstudio.extension/extensions/Get-VSRequiredInstallerVersion.ps1 b/chocolatey-visualstudio.extension/extensions/Get-VSRequiredInstallerVersion.ps1 index 61c21ee2..a38edb8a 100644 --- a/chocolatey-visualstudio.extension/extensions/Get-VSRequiredInstallerVersion.ps1 +++ b/chocolatey-visualstudio.extension/extensions/Get-VSRequiredInstallerVersion.ps1 @@ -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 @@ -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 diff --git a/chocolatey-visualstudio.extension/extensions/Install-VSInstaller.ps1 b/chocolatey-visualstudio.extension/extensions/Install-VSInstaller.ps1 index 79efdafb..010ac606 100644 --- a/chocolatey-visualstudio.extension/extensions/Install-VSInstaller.ps1 +++ b/chocolatey-visualstudio.extension/extensions/Install-VSInstaller.ps1 @@ -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 @@ -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 } } diff --git a/chocolatey-visualstudio.extension/extensions/Start-VisualStudioModifyOperation.ps1 b/chocolatey-visualstudio.extension/extensions/Start-VisualStudioModifyOperation.ps1 index b2ec287e..abbad048 100644 --- a/chocolatey-visualstudio.extension/extensions/Start-VisualStudioModifyOperation.ps1 +++ b/chocolatey-visualstudio.extension/extensions/Start-VisualStudioModifyOperation.ps1 @@ -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