Skip to content

Commit

Permalink
chocolatey-visualstudio.extension: Start-VisualStudioModifyOperation:…
Browse files Browse the repository at this point in the history
… use detected instance info for installer update

GitHub-Issue: GH-7 GH-8 GH-10 GH-26
  • Loading branch information
jberezanski committed May 15, 2018
1 parent 3df1609 commit 32bee83
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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"))
Expand Down

0 comments on commit 32bee83

Please sign in to comment.