Skip to content

Commit a574176

Browse files
committed
Use curl with --retry
1 parent 79b5dd5 commit a574176

File tree

3 files changed

+28
-81
lines changed

3 files changed

+28
-81
lines changed

.github/workflows/scripts/windows/install-vsb.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,28 @@
1010
##
1111
##===----------------------------------------------------------------------===##
1212

13-
Import-Module $PSScriptRoot\web-request-utils.psm1
14-
1513
$VSB='https://download.visualstudio.microsoft.com/download/pr/5536698c-711c-4834-876f-2817d31a2ef2/c792bdb0fd46155de19955269cac85d52c4c63c23db2cf43d96b9390146f9390/vs_BuildTools.exe'
1614
$VSB_SHA256='C792BDB0FD46155DE19955269CAC85D52C4C63C23DB2CF43D96B9390146F9390'
1715
Set-Variable ErrorActionPreference Stop
1816
Set-Variable ProgressPreference SilentlyContinue
1917
Write-Host -NoNewLine ('Downloading {0} ... ' -f ${VSB})
2018
try {
21-
Invoke-WebRequestWithRetry -Uri $VSB -OutFile $env:TEMP\vs_buildtools.exe
19+
# Use curl with retry logic (10 retries with built-in exponential backoff)
20+
$exitCode = (Start-Process -FilePath "curl" -ArgumentList @(
21+
"--retry", "10",
22+
"--retry-max-time", "300",
23+
"--location",
24+
"--output", "$env:TEMP\vs_buildtools.exe",
25+
$VSB
26+
) -Wait -PassThru -NoNewWindow).ExitCode
27+
28+
if ($exitCode -ne 0) {
29+
throw "curl failed with exit code $exitCode"
30+
}
31+
Write-Host 'SUCCESS'
2232
}
2333
catch {
34+
Write-Host "FAILED: $($_.Exception.Message)"
2435
exit 1
2536
}
2637
Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $VSB_SHA256)

.github/workflows/scripts/windows/swift/install-swift.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
##
1111
##===----------------------------------------------------------------------===##
1212

13-
Import-Module $PSScriptRoot\..\web-request-utils.psm1
14-
1513
function Install-Swift {
1614
param (
1715
[string]$Url,
@@ -21,9 +19,22 @@ function Install-Swift {
2119
Set-Variable ProgressPreference SilentlyContinue
2220
Write-Host -NoNewLine ('Downloading {0} ... ' -f $url)
2321
try {
24-
Invoke-WebRequestWithRetry -Uri $url -OutFile installer.exe
22+
# Use curl with retry logic (10 retries with built-in exponential backoff)
23+
$exitCode = (Start-Process -FilePath "curl" -ArgumentList @(
24+
"--retry", "10",
25+
"--retry-max-time", "300",
26+
"--location",
27+
"--output", "installer.exe",
28+
$url
29+
) -Wait -PassThru -NoNewWindow).ExitCode
30+
31+
if ($exitCode -ne 0) {
32+
throw "curl failed with exit code $exitCode"
33+
}
34+
Write-Host 'SUCCESS'
2535
}
2636
catch {
37+
Write-Host "FAILED: $($_.Exception.Message)"
2738
exit 1
2839
}
2940
Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $Sha256)

.github/workflows/scripts/windows/web-request-utils.psm1

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)