зеркало из https://github.com/dotnet/aspnetcore.git
Better retries (#22898)
This commit is contained in:
Родитель
0a0c333f3a
Коммит
46d012d13b
|
@ -0,0 +1,47 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Downloads a given URI and saves it to outputFile
|
||||
.DESCRIPTION
|
||||
Downloads a given URI and saves it to outputFile
|
||||
PARAMETER uri
|
||||
The URI to fetch
|
||||
.PARAMETER outputFile
|
||||
The outputh file path to save the URI
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
$uri,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
$outputFile
|
||||
)
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit
|
||||
|
||||
$maxRetries = 5
|
||||
$retries = 1
|
||||
|
||||
while($true) {
|
||||
try {
|
||||
Write-Host "GET $uri"
|
||||
Invoke-WebRequest $uri -OutFile $outputFile
|
||||
break
|
||||
}
|
||||
catch {
|
||||
Write-Host "Failed to download '$uri'"
|
||||
$error = $_.Exception.Message
|
||||
}
|
||||
|
||||
if (++$retries -le $maxRetries) {
|
||||
Write-Warning $error -ErrorAction Continue
|
||||
$delayInSeconds = [math]::Pow(2, $retries) - 1 # Exponential backoff
|
||||
Write-Host "Retrying. Waiting for $delayInSeconds seconds before next attempt ($retries of $maxRetries)."
|
||||
Start-Sleep -Seconds $delayInSeconds
|
||||
}
|
||||
else {
|
||||
Write-Error $error -ErrorAction Continue
|
||||
throw "Unable to download file in $maxRetries attempts."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Download of '$uri' complete, saved to $outputFile..."
|
|
@ -0,0 +1,35 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Installs dotnet sdk and runtime using https://dot.net/v1/dotnet-install.ps1
|
||||
.DESCRIPTION
|
||||
Installs dotnet sdk and runtime using https://dot.net/v1/dotnet-install.ps1
|
||||
.PARAMETER arch
|
||||
The architecture to install.
|
||||
.PARAMETER sdkVersion
|
||||
The sdk version to install
|
||||
.PARAMETER runtimeVersion
|
||||
The runtime version to install
|
||||
.PARAMETER installDir
|
||||
The directory to install to
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
$arch,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
$sdkVersion,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
$runtimeVersion,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
$installDir
|
||||
)
|
||||
|
||||
& $PSScriptRoot\Download.ps1 "https://dot.net/v1/dotnet-install.ps1" $PSScriptRoot\dotnet-install.ps1
|
||||
Write-Host "Download of dotnet-install.ps1 complete..."
|
||||
Write-Host "Installing SDK...& $PSScriptRoot\dotnet-install.ps1 -Architecture $arch -Version $sdkVersion -InstallDir $installDir"
|
||||
Invoke-Expression "& $PSScriptRoot\dotnet-install.ps1 -Architecture $arch -Version $sdkVersion -InstallDir $installDir"
|
||||
Write-Host "Installing Runtime...& $PSScriptRoot\dotnet-install.ps1 -Architecture $arch -Runtime dotnet -Version $runtimeVersion -InstallDir $installDir"
|
||||
Invoke-Expression "& $PSScriptRoot\dotnet-install.ps1 -Architecture $arch -Runtime dotnet -Version $runtimeVersion -InstallDir $installDir"
|
||||
Write-Host "InstallDotNet.ps1 complete..."
|
|
@ -45,7 +45,7 @@ Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
|
|||
mkdir $tempDir -ea Ignore | out-null
|
||||
mkdir $installDir -ea Ignore | out-null
|
||||
Write-Host "Starting download of JDK ${JdkVersion}"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" -OutFile "$tempDir/jdk.zip"
|
||||
& $PSScriptRoot\Download.ps1 "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" $tempDir/jdk.zip
|
||||
Write-Host "Done downloading JDK ${JdkVersion}"
|
||||
|
||||
Add-Type -assembly "System.IO.Compression.FileSystem"
|
||||
|
|
|
@ -38,7 +38,7 @@ if (Test-Path "$InstallDir\node.exe")
|
|||
$nodeFile="node-v$Version-win-x64"
|
||||
$url="http://nodejs.org/dist/v$Version/$nodeFile.zip"
|
||||
Write-Host "Starting download of NodeJs ${Version} from $url"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "$url" -OutFile "nodejs.zip"
|
||||
& $PSScriptRoot\Download.ps1 $url nodejs.zip
|
||||
Write-Host "Done downloading NodeJS ${Version}"
|
||||
|
||||
$tempPath = [System.IO.Path]::GetTempPath()
|
||||
|
|
|
@ -31,8 +31,7 @@ $installerFilename = "SqlLocalDB.msi"
|
|||
$installerPath = "$intermedateDir\$installerFilename"
|
||||
Write-Host ""
|
||||
Write-Host "Downloading '$installerFilename' to '$installerPath'."
|
||||
Invoke-WebRequest -OutFile $installerPath -UseBasicParsing `
|
||||
-Uri 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SqlLocalDB.msi'
|
||||
& $PSScriptRoot\Download.ps1 'https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SqlLocalDB.msi' $installerPath
|
||||
|
||||
# Install LocalDB.
|
||||
$arguments = '/package', "`"$installerPath`"", '/NoRestart', '/Passive', `
|
||||
|
|
|
@ -24,10 +24,8 @@ set DOTNET_CLI_HOME=%HELIX_CORRELATION_PAYLOAD%\home
|
|||
|
||||
set PATH=%DOTNET_ROOT%;!PATH!;%HELIX_CORRELATION_PAYLOAD%\node\bin
|
||||
echo Set path to: %PATH%
|
||||
echo "Installing SDK"
|
||||
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture %$arch% -Version %$sdkVersion% -InstallDir %DOTNET_ROOT%"
|
||||
echo "Installing Runtime"
|
||||
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture %$arch% -Runtime dotnet -Version %$runtimeVersion% -InstallDir %DOTNET_ROOT%"
|
||||
echo "Invoking InstallDotNet.ps1 %$arch% %$sdkVersion% %$runtimeVersion% %DOTNET_ROOT%"
|
||||
powershell.exe -NoProfile -ExecutionPolicy unrestricted -file InstallDotNet.ps1 %$arch% %$sdkVersion% %$runtimeVersion% %DOTNET_ROOT%
|
||||
|
||||
set exit_code=0
|
||||
echo "Restore: dotnet restore RunTests\RunTests.csproj --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json --ignore-failed-sources..."
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Downloads a given uri and saves it to outputFile
|
||||
.DESCRIPTION
|
||||
Downloads a given uri and saves it to outputFile
|
||||
PARAMETER uri
|
||||
The uri to fetch
|
||||
.PARAMETER outputFile
|
||||
The outputh file path to save the uri
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
$uri,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
$outputFile
|
||||
)
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit
|
||||
|
||||
$maxRetries = 5
|
||||
$retries = 1
|
||||
|
||||
while($true) {
|
||||
try {
|
||||
Write-Host "GET $uri"
|
||||
Invoke-WebRequest $uri -OutFile $outputFile
|
||||
break
|
||||
}
|
||||
catch {
|
||||
Write-Host "Failed to download '$uri'"
|
||||
$error = $_.Exception.Message
|
||||
}
|
||||
|
||||
if (++$retries -le $maxRetries) {
|
||||
Write-Warning $error -ErrorAction Continue
|
||||
$delayInSeconds = [math]::Pow(2, $retries) - 1 # Exponential backoff
|
||||
Write-Host "Retrying. Waiting for $delayInSeconds seconds before next attempt ($retries of $maxRetries)."
|
||||
Start-Sleep -Seconds $delayInSeconds
|
||||
}
|
||||
else {
|
||||
Write-Error $error -ErrorAction Continue
|
||||
throw "Unable to download file in $maxRetries attempts."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Download of '$uri' complete, saved to $outputFile..."
|
|
@ -1,4 +1,4 @@
|
|||
$InstallerPath = "$env:Temp\chrome_installer.exe";
|
||||
Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $InstallerPath;
|
||||
& $PSScriptRoot\Download.ps1 "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" $InstallerPath
|
||||
Start-Process -FilePath $InstallerPath -Args "/silent /install" -Verb RunAs -Wait;
|
||||
Remove-Item $InstallerPath
|
||||
|
|
|
@ -39,7 +39,7 @@ Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
|
|||
mkdir $tempDir -ea Ignore | out-null
|
||||
mkdir $installDir -ea Ignore | out-null
|
||||
Write-Host "Starting download of JDK ${JdkVersion}"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" -Out "$tempDir/jdk.zip"
|
||||
& $PSScriptRoot\Download.ps1 "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/java/jdk-${JdkVersion}_windows-x64_bin.zip" "$tempDir/jdk.zip"
|
||||
Write-Host "Done downloading JDK ${JdkVersion}"
|
||||
Expand-Archive "$tempDir/jdk.zip" -d "$tempDir/jdk/"
|
||||
Write-Host "Expanded JDK to $tempDir"
|
||||
|
|
|
@ -32,7 +32,7 @@ Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
|
|||
mkdir $tempDir -ea Ignore | out-null
|
||||
mkdir $installDir -ea Ignore | out-null
|
||||
Write-Host "Starting ProcDump download"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "https://download.sysinternals.com/files/Procdump.zip" -Out "$tempDir/ProcDump.zip"
|
||||
& $PSScriptRoot\Download.ps1 "https://download.sysinternals.com/files/Procdump.zip" "$tempDir/ProcDump.zip"
|
||||
Write-Host "Done downloading ProcDump"
|
||||
Expand-Archive "$tempDir/ProcDump.zip" -d "$tempDir/ProcDump/"
|
||||
Write-Host "Expanded ProcDump to $tempDir"
|
||||
|
|
Загрузка…
Ссылка в новой задаче