forked from dotnet/coreclr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor dotnet download code in init-tools.cmd (dotnet#10527)
* Refactor dotnet download code in init-tools.cmd This addresses the improvements proposed in issue #10526. Includes the init-tools.cmd script refactor and a new script called dotnet-download.ps1 which includes the extracted code and logic * Code review feedback changes * Fix spacing
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
param( | ||
[parameter(Mandatory=$true)]$DotnetRemotePath, | ||
[parameter(Mandatory=$true)]$DotnetLocalPath, | ||
[parameter(Mandatory=$true)]$DotnetPath | ||
) | ||
|
||
$retryCount = 0 | ||
$success = $false | ||
|
||
do { | ||
try { | ||
Write-Output "Downloading from $DotnetRemotePath" | ||
(New-Object Net.WebClient).DownloadFile($DotnetRemotePath, $DotnetLocalPath) | ||
$success = $true | ||
} catch { | ||
if ($retryCount -ge 6) { | ||
Write-Output "Maximum of 5 retries exceeded. Aborting" | ||
throw | ||
} | ||
else { | ||
$retryCount++ | ||
$retryTime = 5 * $retryCount | ||
Write-Output "Download failed. Retrying in $retryTime seconds" | ||
Start-Sleep -Seconds (5 * $retryCount) | ||
} | ||
} | ||
} while ($success -eq $false) | ||
|
||
Write-Output "Download finished" | ||
Add-Type -Assembly 'System.IO.Compression.FileSystem' -ErrorVariable AddTypeErrors | ||
|
||
if ($AddTypeErrors.Count -eq 0) { | ||
[System.IO.Compression.ZipFile]::ExtractToDirectory($DotnetLocalPath, $DotnetPath) | ||
} | ||
else { | ||
(New-Object -com shell.application).namespace($DotnetPath).CopyHere((new-object -com shell.application).namespace($DotnetLocalPath).Items(), 16) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters