From a56e30c8d33048216567753d9d3fefc2152af8ac Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Thu, 13 Apr 2017 14:17:19 +0900 Subject: Imported Upstream version 2.0.0.11353 --- dotnet-download.ps1 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 dotnet-download.ps1 (limited to 'dotnet-download.ps1') diff --git a/dotnet-download.ps1 b/dotnet-download.ps1 new file mode 100644 index 0000000000..ef5808f2a2 --- /dev/null +++ b/dotnet-download.ps1 @@ -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) +} \ No newline at end of file -- cgit v1.2.3