Skip to content

Commit 00b8361

Browse files
🩹 [Patch]: Add retry logic for installing PSSemVer in Publish-PSModule script
1 parent 74c26dc commit 00b8361

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎scripts/main.ps1‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
[CmdletBinding()]
22
param()
33

4+
$retryCount = 5
5+
$retryDelay = 10
6+
for ($i = 0; $i -lt $retryCount; $i++) {
7+
try {
8+
Install-PSResource -Name 'PSSemVer' -TrustRepository -Repository PSGallery
9+
break
10+
} catch {
11+
Write-Warning "Installation of $($psResourceParams.Name) failed with error: $_"
12+
if ($i -eq $retryCount - 1) {
13+
throw
14+
}
15+
Write-Warning "Retrying in $retryDelay seconds..."
16+
Start-Sleep -Seconds $retryDelay
17+
}
18+
}
19+
420
$path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers')
521
LogGroup "Loading helper scripts from [$path]" {
622
Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | ForEach-Object {

0 commit comments

Comments
 (0)