Created
June 24, 2020 22:08
-
-
Save TheCakeIsNaOH/d382fb7760fe7167ef45eee16731eaac to your computer and use it in GitHub Desktop.
Use a packages.config with the chocolatey global directory override.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[parameter(Mandatory=$false, Position=1)][string]$installDir = 'C:\', | |
[parameter(Mandatory=$false, Position=0)][string]$pkgConfigPath = (Join-Path "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" 'install.config') | |
) | |
if (!(Test-Path $installDir)) { | |
Throw 'did not find override directory' | |
} | |
if (!(Test-Path $pkgConfigPath)) { | |
Throw 'did not find package config file' | |
} | |
[xml]$pkgConfig = Get-Content $pkgConfigPath | |
$pkgConfig.packages.package.id | ForEach-Object { | |
$overrideDir = (Join-Path $installDir $_) | |
#Write-Host $overrideDir | |
If (!(Test-Path $overrideDir)) { | |
$null = New-Item -ItemType Directory -Path $overrideDir | |
} | |
Start-Process -FilePath "choco" -ArgumentList "install $_ --install-directory=$overrideDir" -NoNewWindow -Wait | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment