ray/.buildkite/windows/install/scripts/ImageHelpers/ChocoHelpers.ps1
2021-09-03 11:41:06 -07:00

32 lines
No EOL
902 B
PowerShell

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