diff --git a/chocolatey-visualstudio.extension/extensions/New-VSProductReference.ps1 b/chocolatey-visualstudio.extension/extensions/New-VSProductReference.ps1 new file mode 100644 index 00000000..8bf5e21e --- /dev/null +++ b/chocolatey-visualstudio.extension/extensions/New-VSProductReference.ps1 @@ -0,0 +1,17 @@ +function New-VSProductReference +{ + [CmdletBinding()] + Param + ( + [Parameter(Mandatory = $true)] [string] $ChannelId, + [Parameter(Mandatory = $true)] [string] $ProductId + ) + + $props = @{ + ChannelId = $ChannelId + ProductId = $ProductId + } + + $obj = New-Object -TypeName PSObject -Property $props + return $obj +} diff --git a/chocolatey-visualstudio.extension/extensions/Start-VisualStudioModifyOperation.ps1 b/chocolatey-visualstudio.extension/extensions/Start-VisualStudioModifyOperation.ps1 index bea258ad..ac2637d4 100644 --- a/chocolatey-visualstudio.extension/extensions/Start-VisualStudioModifyOperation.ps1 +++ b/chocolatey-visualstudio.extension/extensions/Start-VisualStudioModifyOperation.ps1 @@ -194,16 +194,12 @@ $argumentSet = $baseArgumentSet.Clone() $argumentSet['installPath'] = $productInfo.installationPath + $argumentSet['__internal_productReference'] = New-VSProductReference -ChannelId $productInfo.channelId -ProductId $productInfo.productid $argumentSets += $argumentSet } } - # todo: move this inside the foreach, so that we can take advantage of channelId - if ($Operation -ne 'uninstall') - { - Install-VSInstaller -PackageName $PackageName -PackageParameters $PackageParameters -ProductReference $ProductReference -Url $BootstrapperUrl -Checksum $BootstrapperChecksum -ChecksumType $BootstrapperChecksumType -Force - } - + $installerUpdated = $false $overallExitCode = 0 foreach ($argumentSet in $argumentSets) { @@ -216,6 +212,23 @@ Write-Debug "Modifying Visual Studio product: [productId = '$($argumentSet.productId)' channelId = '$($argumentSet.channelId)']" } + $thisProductReference = $ProductReference + if ($argumentSet.ContainsKey('__internal_productReference')) + { + $thisProductReference = $argumentSet['__internal_productReference'] + $argumentSet.Remove('__internal_productReference') + } + + if ($Operation -ne 'uninstall' -and -not $installerUpdated) + { + if ($PSCmdlet.ShouldProcess("Visual Studio Installer", "update")) + { + # TODO: download VS component manifest and determine required engine version + Install-VSInstaller -PackageName $PackageName -PackageParameters $PackageParameters -ProductReference $thisProductReference -Url $BootstrapperUrl -Checksum $BootstrapperChecksum -ChecksumType $BootstrapperChecksumType -Force + $installerUpdated = $true + } + } + $silentArgs = ConvertTo-ArgumentString -InitialUnstructuredArguments @($Operation) -Arguments $argumentSet -Syntax 'Willow' $exitCode = -1 if ($PSCmdlet.ShouldProcess("Executable: $InstallerPath", "Start with arguments: $silentArgs"))