Skip to content

Commit d2e883d

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

File tree

3 files changed

+38
-81
lines changed

3 files changed

+38
-81
lines changed

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,33 @@
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 exponential backoff starting at 1 second)
20+
# --retry-all-errors ensures we retry on transfer failures (e.g., exit code 18)
21+
# -C - enables resume for partial downloads
22+
$exitCode = (Start-Process -FilePath "curl" -ArgumentList @(
23+
"--retry", "10",
24+
"--retry-delay", "1",
25+
"--retry-all-errors",
26+
"--retry-max-time", "300",
27+
"--location",
28+
"-C", "-",
29+
"--output", "$env:TEMP\vs_buildtools.exe",
30+
$VSB
31+
) -Wait -PassThru -NoNewWindow).ExitCode
32+
33+
if ($exitCode -ne 0) {
34+
throw "curl failed with exit code $exitCode"
35+
}
36+
Write-Host 'SUCCESS'
2237
}
2338
catch {
39+
Write-Host "FAILED: $($_.Exception.Message)"
2440
exit 1
2541
}
2642
Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $VSB_SHA256)

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

Lines changed: 19 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,27 @@ 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 exponential backoff starting at 1 second)
23+
# --retry-all-errors ensures we retry on transfer failures (e.g., exit code 18)
24+
# -C - enables resume for partial downloads
25+
$exitCode = (Start-Process -FilePath "curl" -ArgumentList @(
26+
"--retry", "10",
27+
"--retry-delay", "1",
28+
"--retry-all-errors",
29+
"--retry-max-time", "300",
30+
"--location",
31+
"-C", "-",
32+
"--output", "installer.exe",
33+
$url
34+
) -Wait -PassThru -NoNewWindow).ExitCode
35+
36+
if ($exitCode -ne 0) {
37+
throw "curl failed with exit code $exitCode"
38+
}
39+
Write-Host 'SUCCESS'
2540
}
2641
catch {
42+
Write-Host "FAILED: $($_.Exception.Message)"
2743
exit 1
2844
}
2945
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)