Files
runner-images/images/win/scripts/ImageHelpers/ChocoHelpers.ps1
T

32 lines
933 B
PowerShell
Raw Normal View History

function Choco-Install {
2020-04-14 06:51:57 +01:00
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string] $PackageName,
[string[]] $ArgumentList,
[int] $RetryCount = 5
2020-04-14 06:51:57 +01:00
)
process {
$count = 1
while($true)
{
Write-Host "Running [#$count]: choco install $packageName -y $argumentList"
choco install $packageName -y @argumentList --no-progress
2020-04-14 06:51:57 +01:00
$pkg = choco list --localonly $packageName --exact --all --limitoutput
if ($pkg) {
Write-Host "Package installed: $pkg"
break
2020-04-14 06:51:57 +01:00
}
else {
$count++
if ($count -ge $retryCount) {
Write-Host "Could not install $packageName after $count attempts"
2020-04-14 06:51:57 +01:00
exit 1
}
Start-Sleep -Seconds 30
2020-04-14 06:51:57 +01:00
}
}
2020-04-14 06:51:57 +01:00
}
}