@@ -486,41 +486,37 @@ function Fetch-Dependencies {
486
486
487
487
$WebClient = New-Object Net.WebClient
488
488
489
- $WiXVersion = " 4.0.4"
490
- $WiXURL = " https://www.nuget.org/api/v2/package/wix/$WiXVersion "
491
- $WiXHash = " A9CA12214E61BB49430A8C6E5E48AC5AE6F27DC82573B5306955C4D35F2D34E2"
489
+ function DownloadAndVerify ($URL , $Destination , $Hash ) {
490
+ if (Test-Path $Destination ) {
491
+ return
492
+ }
492
493
493
- if (-not (Test-Path $BinaryCache \WiX- $WiXVersion.zip )) {
494
- Write-Output " WiX not found. Downloading from nuget.org ..."
495
- New-Item - ItemType Directory - ErrorAction Ignore $BinaryCache | Out-Null
494
+ Write-Output " $Destination not found. Downloading ..."
496
495
if ($ToBatch ) {
497
- Write-Output " curl.exe -sL $WiXURL -o $BinaryCache \WiX-$WiXVersion .zip"
496
+ Write-Output " md `" $ ( Split-Path - Path $Destination - Parent) `" "
497
+ Write-Output " curl.exe -sL $URL -o $Destination "
498
+ Write-Output " (certutil -HashFile $Destination SHA256) == $Hash || (exit /b)"
498
499
} else {
499
- $WebClient.DownloadFile ($WiXURL , " $BinaryCache \WiX-$WiXVersion .zip" )
500
- $SHA256 = Get-FileHash - Path " $BinaryCache \WiX-$WiXVersion .zip" - Algorithm SHA256
501
- if ($SHA256.Hash -ne $WiXHash ) {
502
- throw " WiX SHA256 mismatch ($ ( $SHA256.Hash ) vs $WiXHash )"
500
+ New-Item - ItemType Directory (Split-Path - Path $Destination - Parent) - ErrorAction Ignore | Out-Null
501
+ $WebClient.DownloadFile ($URL , $Destination )
502
+ $SHA256 = Get-FileHash - Path $Destination - Algorithm SHA256
503
+ if ($SHA256.Hash -ne $Hash ) {
504
+ throw " SHA256 mismatch ($ ( $SHA256.Hash ) vs $Hash )"
503
505
}
504
506
}
505
507
}
506
508
509
+ $WiXVersion = " 4.0.4"
510
+ $WiXURL = " https://www.nuget.org/api/v2/package/wix/$WiXVersion "
511
+ $WiXHash = " A9CA12214E61BB49430A8C6E5E48AC5AE6F27DC82573B5306955C4D35F2D34E2"
512
+ DownloadAndVerify $WixURL " $BinaryCache \WiX-$WiXVersion .zip" $WiXHash
513
+
507
514
# TODO(compnerd) stamp/validate that we need to re-extract
508
515
New-Item - ItemType Directory - ErrorAction Ignore $BinaryCache \WiX- $WiXVersion | Out-Null
509
516
Write-Output " Extracting WiX ..."
510
517
Expand-Archive - Path $BinaryCache \WiX- $WiXVersion.zip - Destination $BinaryCache \WiX- $WiXVersion - Force
511
518
512
- if (-not (Test-Path $BinaryCache \$PinnedToolchain.exe )) {
513
- Write-Output " Swift toolchain not found. Downloading from swift.org..."
514
- if ($ToBatch ) {
515
- Write-Output " curl.exe -sL $PinnedBuild -o $BinaryCache \$PinnedToolchain .exe"
516
- } else {
517
- $WebClient.DownloadFile (" $PinnedBuild " , " $BinaryCache \$PinnedToolchain .exe" )
518
- $SHA256 = Get-FileHash - Path " $BinaryCache \$PinnedToolchain .exe" - Algorithm SHA256
519
- if ($SHA256.Hash -ne $PinnedSHA256 ) {
520
- throw " $PinnedToolchain SHA256 mismatch ($ ( $SHA256.Hash ) vs $PinnedSHA256 )"
521
- }
522
- }
523
- }
519
+ DownloadAndVerify $PinnedBuild " $BinaryCache \$PinnedToolchain .exe" $PinnedSHA256
524
520
525
521
# TODO(compnerd) stamp/validate that we need to re-extract
526
522
Write-Output " Extracting $PinnedToolchain ..."
0 commit comments