File tree Expand file tree Collapse file tree 3 files changed +33
-81
lines changed
.github/workflows/scripts/windows Expand file tree Collapse file tree 3 files changed +33
-81
lines changed Original file line number Diff line number Diff line change 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'
1715Set-Variable ErrorActionPreference Stop
1816Set-Variable ProgressPreference SilentlyContinue
1917Write-Host - NoNewLine (' Downloading {0} ... ' -f ${VSB} )
2018try {
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}
2333catch {
34+ Write-Host " FAILED: $ ( $_.Exception.Message ) "
2435 exit 1
2536}
2637Write-Host - NoNewLine (' Verifying SHA256 ({0}) ... ' -f $VSB_SHA256 )
Original file line number Diff line number Diff line change 1010# #
1111# #===----------------------------------------------------------------------===##
1212
13- Import-Module $PSScriptRoot \..\web- request-utils .psm1
14-
1513function 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 )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments