Skip to content

Commit

Permalink
chocolatey-visualstudio.extension: fix installing/updating from layout
Browse files Browse the repository at this point in the history
GitHub-Issue: GH-10
  • Loading branch information
jberezanski committed May 15, 2018
1 parent ad97475 commit 5e9bfdd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
Expand Up @@ -84,6 +84,21 @@ function Install-VSInstaller
return
}

# if installing from layout, check for existence of vs_installer.opc and auto add --offline
if (-not $packageParameters.ContainsKey('offline'))
{
$layoutPath = Resolve-VSLayoutPath -PackageParameters $PackageParameters
if ($layoutPath -ne $null)
{
$installerOpcPath = Join-Path -Path $layoutPath -ChildPath 'vs_installer.opc'
if (Test-Path -Path $installerOpcPath)
{
Write-Debug "Using the VS Installer package present in the layout path: $installerOpcPath"
$packageParameters['offline'] = $installerOpcPath
}
}
}

if ($packageParameters.ContainsKey('bootstrapperPath'))
{
$installerFilePath = $packageParameters['bootstrapperPath']
Expand Down Expand Up @@ -112,21 +127,6 @@ function Install-VSInstaller
$PackageParameters.Remove($parameterToRemove)
}

# if installing from layout, check for existence of vs_installer.opc and auto add --offline
if (-not $packageParameters.ContainsKey('offline'))
{
$layoutPath = Resolve-VSLayoutPath -PackageParameters $PackageParameters
if ($layoutPath -ne $null)
{
$installerOpcPath = Join-Path -Path $layoutPath -ChildPath 'vs_installer.opc'
if (Test-Path -Path $installerOpcPath)
{
Write-Debug "Using the VS Installer package present in the layout path: $installerOpcPath"
$packageParameters['offline'] = $installerOpcPath
}
}
}

# --update must be last
$packageParameters['quiet'] = $null
$silentArgs = ConvertTo-ArgumentString -Arguments $packageParameters -FinalUnstructuredArguments @('--update') -Syntax 'Willow'
Expand Down
Expand Up @@ -122,8 +122,6 @@ Install-ChocolateyPackage
Write-Debug "Log file path: $logFilePath"
}

$silentArgs = Generate-InstallArgumentsString -parameters $packageParameters -adminFile $adminFile -logFilePath $logFilePath -assumeNewVS2017Installer:$assumeNewVS2017Installer

if ($creatingLayout)
{
$layoutPath = $packageParameters['layout']
Expand All @@ -135,6 +133,19 @@ Install-ChocolateyPackage
Assert-VSInstallerUpdated -PackageName $PackageName -PackageParameters $PackageParameters -ProductReference $productReference -Url $Url -Checksum $Checksum -ChecksumType $ChecksumType
}

if ($packageParameters.ContainsKey('bootstrapperPath'))
{
$installerFilePath = $packageParameters['bootstrapperPath']
$packageParameters.Remove('bootstrapperPath')
Write-Debug "User-provided bootstrapper path: $installerFilePath"
}
else
{
$installerFilePath = $null
}

$silentArgs = Generate-InstallArgumentsString -parameters $packageParameters -adminFile $adminFile -logFilePath $logFilePath -assumeNewVS2017Installer:$assumeNewVS2017Installer

$arguments = @{
packageName = $PackageName
silentArgs = $silentArgs
Expand Down
Expand Up @@ -242,6 +242,21 @@
throw 'The Visual Studio Installer is not present. Unable to continue.'
}

# TODO: Resolve-VSLayoutPath and auto add --installLayoutPath

$blacklist = @('bootstrapperPath')
$parametersToRemove = $argumentSet.Keys | Where-Object { $blacklist -contains $_ }
foreach ($parameterToRemove in $parametersToRemove)
{
if ($parameterToRemove -eq $null)
{
continue
}

Write-Debug "Filtering out package parameter not passed to the VS Installer: '$parameterToRemove'"
$argumentSet.Remove($parameterToRemove)
}

$silentArgs = ConvertTo-ArgumentString -InitialUnstructuredArguments @($Operation) -Arguments $argumentSet -Syntax 'Willow'
$exitCode = -1
if ($PSCmdlet.ShouldProcess("Executable: $($installer.Path)", "Start with arguments: $silentArgs"))
Expand Down

0 comments on commit 5e9bfdd

Please sign in to comment.