зеркало из https://github.com/aspnet/KoreBuild.git
Update dotnet install scripts to match the version in CLI (commit: 94107dc7f6234c4724859c3087724e7900dfca42)
This commit is contained in:
Родитель
5d68a97b12
Коммит
f54febe9ea
|
@ -80,7 +80,7 @@ $VersionRegEx="/\d+\.\d+[^/]+/"
|
|||
$OverrideNonVersionedFiles=$true
|
||||
|
||||
function Say($str) {
|
||||
Write-Host "dotnet-install: $str"
|
||||
Write-Output "dotnet-install: $str"
|
||||
}
|
||||
|
||||
function Say-Verbose($str) {
|
||||
|
@ -93,6 +93,25 @@ function Say-Invocation($Invocation) {
|
|||
Say-Verbose "$command $args"
|
||||
}
|
||||
|
||||
function Invoke-With-Retry([ScriptBlock]$ScriptBlock, [int]$MaxAttempts = 3, [int]$SecondsBetweenAttempts = 1) {
|
||||
$Attempts = 0
|
||||
|
||||
while ($true) {
|
||||
try {
|
||||
return $ScriptBlock.Invoke()
|
||||
}
|
||||
catch {
|
||||
$Attempts++
|
||||
if ($Attempts -lt $MaxAttempts) {
|
||||
Start-Sleep $SecondsBetweenAttempts
|
||||
}
|
||||
else {
|
||||
throw
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-Machine-Architecture() {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
|
@ -135,52 +154,56 @@ function Load-Assembly([string] $Assembly) {
|
|||
|
||||
function GetHTTPResponse([Uri] $Uri)
|
||||
{
|
||||
$HttpClient = $null
|
||||
Invoke-With-Retry(
|
||||
{
|
||||
|
||||
try {
|
||||
# HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet.
|
||||
Load-Assembly -Assembly System.Net.Http
|
||||
$HttpClient = $null
|
||||
|
||||
if(-not $ProxyAddress)
|
||||
{
|
||||
# Despite no proxy being explicitly specified, we may still be behind a default proxy
|
||||
$DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy;
|
||||
if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){
|
||||
$ProxyAddress = $DefaultProxy.GetProxy($Uri).OriginalString
|
||||
$ProxyUseDefaultCredentials = $true
|
||||
}
|
||||
}
|
||||
try {
|
||||
# HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet.
|
||||
Load-Assembly -Assembly System.Net.Http
|
||||
|
||||
if($ProxyAddress){
|
||||
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
|
||||
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress;UseDefaultCredentials=$ProxyUseDefaultCredentials}
|
||||
$HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler
|
||||
}
|
||||
else {
|
||||
$HttpClient = New-Object System.Net.Http.HttpClient
|
||||
}
|
||||
# Default timeout for HttpClient is 100s. For a 50 MB download this assumes 500 KB/s average, any less will time out
|
||||
# 10 minutes allows it to work over much slower connections.
|
||||
$HttpClient.Timeout = New-TimeSpan -Minutes 10
|
||||
$Response = $HttpClient.GetAsync($Uri).Result
|
||||
if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode)))
|
||||
{
|
||||
$ErrorMsg = "Failed to download $Uri."
|
||||
if ($Response -ne $null)
|
||||
if(-not $ProxyAddress)
|
||||
{
|
||||
$ErrorMsg += " $Response"
|
||||
# Despite no proxy being explicitly specified, we may still be behind a default proxy
|
||||
$DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy;
|
||||
if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){
|
||||
$ProxyAddress = $DefaultProxy.GetProxy($Uri).OriginalString
|
||||
$ProxyUseDefaultCredentials = $true
|
||||
}
|
||||
}
|
||||
|
||||
throw $ErrorMsg
|
||||
}
|
||||
if($ProxyAddress){
|
||||
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
|
||||
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress;UseDefaultCredentials=$ProxyUseDefaultCredentials}
|
||||
$HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler
|
||||
}
|
||||
else {
|
||||
$HttpClient = New-Object System.Net.Http.HttpClient
|
||||
}
|
||||
# Default timeout for HttpClient is 100s. For a 50 MB download this assumes 500 KB/s average, any less will time out
|
||||
# 10 minutes allows it to work over much slower connections.
|
||||
$HttpClient.Timeout = New-TimeSpan -Minutes 10
|
||||
$Response = $HttpClient.GetAsync($Uri).Result
|
||||
if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode)))
|
||||
{
|
||||
$ErrorMsg = "Failed to download $Uri."
|
||||
if ($Response -ne $null)
|
||||
{
|
||||
$ErrorMsg += " $Response"
|
||||
}
|
||||
|
||||
return $Response
|
||||
}
|
||||
finally {
|
||||
if ($HttpClient -ne $null) {
|
||||
$HttpClient.Dispose()
|
||||
throw $ErrorMsg
|
||||
}
|
||||
|
||||
return $Response
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if ($HttpClient -ne $null) {
|
||||
$HttpClient.Dispose()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
@ -223,10 +246,23 @@ function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel,
|
|||
}
|
||||
}
|
||||
|
||||
function Get-Download-Links([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) {
|
||||
function Get-Download-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
$ret = @()
|
||||
if ($SharedRuntime) {
|
||||
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-runtime-$SpecificVersion-win-$CLIArchitecture.zip"
|
||||
}
|
||||
else {
|
||||
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-$SpecificVersion-win-$CLIArchitecture.zip"
|
||||
}
|
||||
|
||||
Say-Verbose "Constructed primary payload URL: $PayloadURL"
|
||||
|
||||
return $PayloadURL
|
||||
}
|
||||
|
||||
function Get-AltDownload-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
if ($SharedRuntime) {
|
||||
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip"
|
||||
|
@ -235,10 +271,9 @@ function Get-Download-Links([string]$AzureFeed, [string]$Channel, [string]$Speci
|
|||
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip"
|
||||
}
|
||||
|
||||
Say-Verbose "Constructed payload URL: $PayloadURL"
|
||||
$ret += $PayloadURL
|
||||
Say-Verbose "Constructed alternate payload URL: $PayloadURL"
|
||||
|
||||
return $ret
|
||||
return $PayloadURL
|
||||
}
|
||||
|
||||
function Get-User-Share-Path() {
|
||||
|
@ -396,13 +431,13 @@ function Prepend-Sdk-InstallRoot-To-Path([string]$InstallRoot, [string]$BinFolde
|
|||
|
||||
$CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture
|
||||
$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version
|
||||
$DownloadLinks = Get-Download-Links -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
|
||||
$DownloadLink = Get-Download-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
|
||||
$AltDownloadLink = Get-AltDownload-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
|
||||
|
||||
if ($DryRun) {
|
||||
Say "Payload URLs:"
|
||||
foreach ($DownloadLink in $DownloadLinks) {
|
||||
Say "- $DownloadLink"
|
||||
}
|
||||
Say "Primary - $DownloadLink"
|
||||
Say "Alternate - $AltDownloadLink"
|
||||
Say "Repeatable invocation: .\$($MyInvocation.MyCommand) -Version $SpecificVersion -Channel $Channel -Architecture $CLIArchitecture -InstallDir $InstallDir"
|
||||
exit 0
|
||||
}
|
||||
|
@ -420,23 +455,31 @@ if ($IsSdkInstalled) {
|
|||
|
||||
New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null
|
||||
|
||||
$free = Get-CimInstance -Class win32_logicaldisk | where Deviceid -eq "$((Get-Item $InstallRoot).PSDrive.Name):"
|
||||
if ($free.Freespace / 1MB -le 250 ) {
|
||||
Say "there is not enough disk space on drive c:"
|
||||
$installDrive = $((Get-Item $InstallRoot).PSDrive.Name);
|
||||
Write-Output "${installDrive}:";
|
||||
$free = Get-CimInstance -Class win32_logicaldisk | where Deviceid -eq "${installDrive}:"
|
||||
if ($free.Freespace / 1MB -le 100 ) {
|
||||
Say "There is not enough disk space on drive ${installDrive}:"
|
||||
exit 0
|
||||
}
|
||||
|
||||
foreach ($DownloadLink in $DownloadLinks) {
|
||||
$ZipPath = [System.IO.Path]::GetTempFileName()
|
||||
Say "Downloading $DownloadLink"
|
||||
try {
|
||||
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
|
||||
}
|
||||
catch {
|
||||
$DownloadLink = $AltDownloadLink
|
||||
$ZipPath = [System.IO.Path]::GetTempFileName()
|
||||
Say "Downloading $DownloadLink"
|
||||
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
|
||||
|
||||
Say "Extracting zip from $DownloadLink"
|
||||
Extract-Dotnet-Package -ZipPath $ZipPath -OutPath $InstallRoot
|
||||
|
||||
Remove-Item $ZipPath
|
||||
}
|
||||
|
||||
Say "Extracting zip from $DownloadLink"
|
||||
Extract-Dotnet-Package -ZipPath $ZipPath -OutPath $InstallRoot
|
||||
|
||||
Remove-Item $ZipPath
|
||||
|
||||
Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot -BinFolderRelativePath $BinFolderRelativePath
|
||||
|
||||
Say "Installation finished"
|
||||
|
|
|
@ -398,9 +398,9 @@ construct_download_link() {
|
|||
|
||||
local download_link=null
|
||||
if [ "$shared_runtime" = true ]; then
|
||||
download_link="$azure_feed/Runtime/$specific_version/dotnet-$osname-$normalized_architecture.$specific_version.tar.gz"
|
||||
download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_version-$osname-$normalized_architecture.tar.gz"
|
||||
else
|
||||
download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$osname-$normalized_architecture.$specific_version.tar.gz"
|
||||
download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$specific_version-$osname-$normalized_architecture.tar.gz"
|
||||
fi
|
||||
|
||||
echo "$download_link"
|
||||
|
@ -419,7 +419,7 @@ construct_alt_download_link() {
|
|||
local channel=$2
|
||||
local normalized_architecture=$3
|
||||
local specific_version=${4//[$'\t\r\n']}
|
||||
|
||||
|
||||
local distro_specific_osname
|
||||
distro_specific_osname=$(get_distro_specific_os_name) || return 1
|
||||
|
||||
|
@ -429,7 +429,7 @@ construct_alt_download_link() {
|
|||
else
|
||||
alt_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz"
|
||||
fi
|
||||
|
||||
|
||||
echo "$alt_download_link"
|
||||
return 0
|
||||
}
|
||||
|
@ -623,10 +623,8 @@ calculate_vars() {
|
|||
download_link=$(construct_download_link $azure_feed $channel $normalized_architecture $specific_version)
|
||||
say_verbose "download_link=$download_link"
|
||||
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
alt_download_link=$(construct_alt_download_link $azure_feed $channel $normalized_architecture $specific_version)
|
||||
say_verbose "alt_download_link=$alt_download_link"
|
||||
fi
|
||||
alt_download_link=$(construct_alt_download_link $azure_feed $channel $normalized_architecture $specific_version)
|
||||
say_verbose "alt_download_link=$alt_download_link"
|
||||
|
||||
install_root=$(resolve_installation_path $install_dir)
|
||||
say_verbose "install_root=$install_root"
|
||||
|
@ -648,8 +646,8 @@ install_dotnet() {
|
|||
say "Downloading link: $download_link"
|
||||
download "$download_link" $zip_path || download_failed=true
|
||||
|
||||
# if the download fails, download the alt_download_link [Linux only]
|
||||
if [ "$(uname)" = "Linux" ] && [ "$download_failed" = true ]; then
|
||||
# if the download fails, download the alt_download_link
|
||||
if [ "$download_failed" = true ]; then
|
||||
say "Cannot download: $download_link"
|
||||
zip_path=$(mktemp $temporary_file_template)
|
||||
say_verbose "Alternate zip path: $zip_path"
|
||||
|
@ -776,9 +774,7 @@ check_min_reqs
|
|||
calculate_vars
|
||||
if [ "$dry_run" = true ]; then
|
||||
say "Payload URL: $download_link"
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
say "Alternate payload URL: $alt_download_link"
|
||||
fi
|
||||
say "Alternate payload URL: $alt_download_link"
|
||||
say "Repeatable invocation: ./$(basename $0) --version $specific_version --channel $channel --install-dir $install_dir"
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -1 +1 @@
|
|||
2.0.0-preview2-25324-01
|
||||
2.0.0-preview2-25324-03
|
||||
|
|
Загрузка…
Ссылка в новой задаче