Merge pull request #8333 from natemcmaster/dotnet-install
Update dotnet-install scripts to support installing the ASP.NET Core runtime
This commit is contained in:
commit
e3a19395fb
2 changed files with 166 additions and 78 deletions
61
scripts/obtain/dotnet-install.ps1
vendored
61
scripts/obtain/dotnet-install.ps1
vendored
|
@ -34,8 +34,17 @@
|
||||||
Architecture of dotnet binaries to be installed.
|
Architecture of dotnet binaries to be installed.
|
||||||
Possible values are: <auto>, x64 and x86
|
Possible values are: <auto>, x64 and x86
|
||||||
.PARAMETER SharedRuntime
|
.PARAMETER SharedRuntime
|
||||||
|
This parameter is obsolete and may be removed in a future version of this script.
|
||||||
|
The recommended alternative is '-Runtime dotnet'.
|
||||||
|
|
||||||
Default: false
|
Default: false
|
||||||
Installs just the shared runtime bits, not the entire SDK
|
Installs just the shared runtime bits, not the entire SDK.
|
||||||
|
This is equivalent to specifying `-Runtime dotnet`.
|
||||||
|
.PARAMETER Runtime
|
||||||
|
Installs just a shared runtime, not the entire SDK.
|
||||||
|
Possible values:
|
||||||
|
- dotnet
|
||||||
|
- aspnetcore
|
||||||
.PARAMETER DryRun
|
.PARAMETER DryRun
|
||||||
If set it will not perform installation but instead display what command line to use to consistently install
|
If set it will not perform installation but instead display what command line to use to consistently install
|
||||||
currently requested version of dotnet cli. In example if you specify version 'latest' it will display a link
|
currently requested version of dotnet cli. In example if you specify version 'latest' it will display a link
|
||||||
|
@ -71,6 +80,9 @@ param(
|
||||||
[string]$Version="Latest",
|
[string]$Version="Latest",
|
||||||
[string]$InstallDir="<auto>",
|
[string]$InstallDir="<auto>",
|
||||||
[string]$Architecture="<auto>",
|
[string]$Architecture="<auto>",
|
||||||
|
[ValidateSet("dotnet", "aspnetcore", IgnoreCase = $false)]
|
||||||
|
[string]$Runtime,
|
||||||
|
[Obsolete("This parameter may be removed in a future version of this script. The recommended alternative is '-Runtime dotnet'.")]
|
||||||
[switch]$SharedRuntime,
|
[switch]$SharedRuntime,
|
||||||
[switch]$DryRun,
|
[switch]$DryRun,
|
||||||
[switch]$NoPath,
|
[switch]$NoPath,
|
||||||
|
@ -88,6 +100,10 @@ $ProgressPreference="SilentlyContinue"
|
||||||
|
|
||||||
$BinFolderRelativePath=""
|
$BinFolderRelativePath=""
|
||||||
|
|
||||||
|
if ($SharedRuntime -and (-not $Runtime)) {
|
||||||
|
$Runtime = "dotnet"
|
||||||
|
}
|
||||||
|
|
||||||
# example path with regex: shared/1.0.0-beta-12345/somepath
|
# example path with regex: shared/1.0.0-beta-12345/somepath
|
||||||
$VersionRegEx="/\d+\.\d+[^/]+/"
|
$VersionRegEx="/\d+\.\d+[^/]+/"
|
||||||
$OverrideNonVersionedFiles = !$SkipNonVersionedFiles
|
$OverrideNonVersionedFiles = !$SkipNonVersionedFiles
|
||||||
|
@ -230,9 +246,12 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Co
|
||||||
Say-Invocation $MyInvocation
|
Say-Invocation $MyInvocation
|
||||||
|
|
||||||
$VersionFileUrl = $null
|
$VersionFileUrl = $null
|
||||||
if ($SharedRuntime) {
|
if ($Runtime -eq "dotnet") {
|
||||||
$VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.version"
|
$VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.version"
|
||||||
}
|
}
|
||||||
|
elseif ($Runtime) {
|
||||||
|
$VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.$Runtime.version"
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if ($Coherent) {
|
if ($Coherent) {
|
||||||
$VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.coherent.version"
|
$VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.coherent.version"
|
||||||
|
@ -277,8 +296,8 @@ function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel,
|
||||||
function Get-Download-Link([string]$AzureFeed, [string]$SpecificVersion, [string]$CLIArchitecture) {
|
function Get-Download-Link([string]$AzureFeed, [string]$SpecificVersion, [string]$CLIArchitecture) {
|
||||||
Say-Invocation $MyInvocation
|
Say-Invocation $MyInvocation
|
||||||
|
|
||||||
if ($SharedRuntime) {
|
if ($Runtime) {
|
||||||
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-runtime-$SpecificVersion-win-$CLIArchitecture.zip"
|
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/$Runtime-runtime-$SpecificVersion-win-$CLIArchitecture.zip"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-sdk-$SpecificVersion-win-$CLIArchitecture.zip"
|
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-sdk-$SpecificVersion-win-$CLIArchitecture.zip"
|
||||||
|
@ -292,11 +311,14 @@ function Get-Download-Link([string]$AzureFeed, [string]$SpecificVersion, [string
|
||||||
function Get-LegacyDownload-Link([string]$AzureFeed, [string]$SpecificVersion, [string]$CLIArchitecture) {
|
function Get-LegacyDownload-Link([string]$AzureFeed, [string]$SpecificVersion, [string]$CLIArchitecture) {
|
||||||
Say-Invocation $MyInvocation
|
Say-Invocation $MyInvocation
|
||||||
|
|
||||||
if ($SharedRuntime) {
|
if (-not $Runtime) {
|
||||||
|
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip"
|
||||||
|
}
|
||||||
|
elseif ($Runtime -eq "dotnet") {
|
||||||
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip"
|
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip"
|
return $null
|
||||||
}
|
}
|
||||||
|
|
||||||
Say-Verbose "Constructed legacy payload URL: $PayloadURL"
|
Say-Verbose "Constructed legacy payload URL: $PayloadURL"
|
||||||
|
@ -465,7 +487,9 @@ $LegacyDownloadLink = Get-LegacyDownload-Link -AzureFeed $AzureFeed -SpecificVer
|
||||||
if ($DryRun) {
|
if ($DryRun) {
|
||||||
Say "Payload URLs:"
|
Say "Payload URLs:"
|
||||||
Say "Primary - $DownloadLink"
|
Say "Primary - $DownloadLink"
|
||||||
|
if ($LegacyDownloadLink) {
|
||||||
Say "Legacy - $LegacyDownloadLink"
|
Say "Legacy - $LegacyDownloadLink"
|
||||||
|
}
|
||||||
Say "Repeatable invocation: .\$($MyInvocation.Line)"
|
Say "Repeatable invocation: .\$($MyInvocation.Line)"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
@ -473,10 +497,22 @@ if ($DryRun) {
|
||||||
$InstallRoot = Resolve-Installation-Path $InstallDir
|
$InstallRoot = Resolve-Installation-Path $InstallDir
|
||||||
Say-Verbose "InstallRoot: $InstallRoot"
|
Say-Verbose "InstallRoot: $InstallRoot"
|
||||||
|
|
||||||
$IsSdkInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage "sdk" -SpecificVersion $SpecificVersion
|
if ($Runtime -eq "dotnet") {
|
||||||
Say-Verbose ".NET SDK installed? $IsSdkInstalled"
|
$assetName = ".NET Core Runtime"
|
||||||
if ($IsSdkInstalled) {
|
$dotnetPackageRelativePath = "shared\Microsoft.NETCore.App"
|
||||||
Say ".NET SDK version $SpecificVersion is already installed."
|
}
|
||||||
|
elseif ($Runtime -eq "aspnetcore") {
|
||||||
|
$assetName = "ASP.NET Core Runtime"
|
||||||
|
$dotnetPackageRelativePath = "shared\Microsoft.AspNetCore.All"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$assetName = ".NET Core SDK"
|
||||||
|
$dotnetPackageRelativePath = "sdk"
|
||||||
|
}
|
||||||
|
|
||||||
|
$isAssetInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage $dotnetPackageRelativePath -SpecificVersion $SpecificVersion
|
||||||
|
if ($isAssetInstalled) {
|
||||||
|
Say "$assetName version $SpecificVersion is already installed."
|
||||||
Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot -BinFolderRelativePath $BinFolderRelativePath
|
Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot -BinFolderRelativePath $BinFolderRelativePath
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
@ -498,11 +534,16 @@ try {
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Say "Cannot download: $DownloadLink"
|
Say "Cannot download: $DownloadLink"
|
||||||
|
if ($LegacyDownloadLink) {
|
||||||
$DownloadLink = $LegacyDownloadLink
|
$DownloadLink = $LegacyDownloadLink
|
||||||
$ZipPath = [System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
|
$ZipPath = [System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
|
||||||
Say-Verbose "Legacy zip path: $ZipPath"
|
Say-Verbose "Legacy zip path: $ZipPath"
|
||||||
Say "Downloading legacy link: $DownloadLink"
|
Say "Downloading legacy link: $DownloadLink"
|
||||||
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
|
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw "Could not download $assetName version $SpecificVersion"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Say "Extracting zip from $DownloadLink"
|
Say "Extracting zip from $DownloadLink"
|
||||||
|
|
75
scripts/obtain/dotnet-install.sh
vendored
75
scripts/obtain/dotnet-install.sh
vendored
|
@ -39,6 +39,10 @@ if [ -t 1 ] && command -v tput > /dev/null; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
say_warning() {
|
||||||
|
printf "%b\n" "${yellow:-}dotnet_install: Warning: $1${normal:-}"
|
||||||
|
}
|
||||||
|
|
||||||
say_err() {
|
say_err() {
|
||||||
printf "%b\n" "${red:-}dotnet_install: Error: $1${normal:-}" >&2
|
printf "%b\n" "${red:-}dotnet_install: Error: $1${normal:-}" >&2
|
||||||
}
|
}
|
||||||
|
@ -384,8 +388,10 @@ get_latest_version_info() {
|
||||||
local coherent="$4"
|
local coherent="$4"
|
||||||
|
|
||||||
local version_file_url=null
|
local version_file_url=null
|
||||||
if [ "$shared_runtime" = true ]; then
|
if [[ "$runtime" == "dotnet" ]]; then
|
||||||
version_file_url="$uncached_feed/Runtime/$channel/latest.version"
|
version_file_url="$uncached_feed/Runtime/$channel/latest.version"
|
||||||
|
elif [ ! -z "$runtime" ]; then
|
||||||
|
version_file_url="$uncached_feed/Runtime/$channel/latest.$runtime.version"
|
||||||
else
|
else
|
||||||
if [ "$coherent" = true ]; then
|
if [ "$coherent" = true ]; then
|
||||||
version_file_url="$uncached_feed/Sdk/$channel/latest.coherent.version"
|
version_file_url="$uncached_feed/Sdk/$channel/latest.coherent.version"
|
||||||
|
@ -451,8 +457,8 @@ construct_download_link() {
|
||||||
osname="$(get_current_os_name)" || return 1
|
osname="$(get_current_os_name)" || return 1
|
||||||
|
|
||||||
local download_link=null
|
local download_link=null
|
||||||
if [ "$shared_runtime" = true ]; then
|
if [ ! -z "$runtime" ]; then
|
||||||
download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_version-$osname-$normalized_architecture.tar.gz"
|
download_link="$azure_feed/Runtime/$specific_version/$runtime-runtime-$specific_version-$osname-$normalized_architecture.tar.gz"
|
||||||
else
|
else
|
||||||
download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_version-$osname-$normalized_architecture.tar.gz"
|
download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_version-$osname-$normalized_architecture.tar.gz"
|
||||||
fi
|
fi
|
||||||
|
@ -478,10 +484,12 @@ construct_legacy_download_link() {
|
||||||
distro_specific_osname="$(get_legacy_os_name)" || return 1
|
distro_specific_osname="$(get_legacy_os_name)" || return 1
|
||||||
|
|
||||||
local legacy_download_link=null
|
local legacy_download_link=null
|
||||||
if [ "$shared_runtime" = true ]; then
|
if [[ "$runtime" == "dotnet" ]]; then
|
||||||
legacy_download_link="$azure_feed/Runtime/$specific_version/dotnet-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz"
|
legacy_download_link="$azure_feed/Runtime/$specific_version/dotnet-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz"
|
||||||
else
|
elif [ -z "$runtime" ]; then
|
||||||
legacy_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz"
|
legacy_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz"
|
||||||
|
else
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$legacy_download_link"
|
echo "$legacy_download_link"
|
||||||
|
@ -691,9 +699,22 @@ calculate_vars() {
|
||||||
install_dotnet() {
|
install_dotnet() {
|
||||||
eval $invocation
|
eval $invocation
|
||||||
local download_failed=false
|
local download_failed=false
|
||||||
|
local asset_name=''
|
||||||
|
local asset_relative_path=''
|
||||||
|
|
||||||
if is_dotnet_package_installed "$install_root" "sdk" "$specific_version"; then
|
if [[ "$runtime" == "dotnet" ]]; then
|
||||||
say ".NET SDK version $specific_version is already installed."
|
asset_relative_path="shared/Microsoft.NETCore.App"
|
||||||
|
asset_name=".NET Core Runtime"
|
||||||
|
elif [[ "$runtime" == "aspnetcore" ]]; then
|
||||||
|
asset_relative_path="shared/Microsoft.AspNetCore.All"
|
||||||
|
asset_name="ASP.NET Core Runtime"
|
||||||
|
else
|
||||||
|
asset_relative_path="sdk"
|
||||||
|
asset_name=".NET Core SDK"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$specific_version"; then
|
||||||
|
say "$asset_name version $specific_version is already installed."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -708,13 +729,22 @@ install_dotnet() {
|
||||||
download "$download_link" "$zip_path" 2>&1 || download_failed=true
|
download "$download_link" "$zip_path" 2>&1 || download_failed=true
|
||||||
|
|
||||||
# if the download fails, download the legacy_download_link
|
# if the download fails, download the legacy_download_link
|
||||||
if [ "$download_failed" = true ] && [ "$valid_legacy_download_link" = true ]; then
|
if [ "$download_failed" = true ]; then
|
||||||
say "Cannot download: $download_link"
|
say "Cannot download: $download_link"
|
||||||
|
|
||||||
|
if [ "$valid_legacy_download_link" = true ]; then
|
||||||
|
download_failed=false
|
||||||
download_link="$legacy_download_link"
|
download_link="$legacy_download_link"
|
||||||
zip_path="$(mktemp "$temporary_file_template")"
|
zip_path="$(mktemp "$temporary_file_template")"
|
||||||
say_verbose "Legacy zip path: $zip_path"
|
say_verbose "Legacy zip path: $zip_path"
|
||||||
say "Downloading legacy link: $download_link"
|
say "Downloading legacy link: $download_link"
|
||||||
download "$download_link" "$zip_path"
|
download "$download_link" "$zip_path" 2>&1 || download_failed=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$download_failed" = true ]; then
|
||||||
|
say_err "Could not download $asset_name version $specific_version"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
say "Extracting zip from $download_link"
|
say "Extracting zip from $download_link"
|
||||||
|
@ -737,7 +767,7 @@ azure_feed="https://dotnetcli.azureedge.net/dotnet"
|
||||||
uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet"
|
uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet"
|
||||||
feed_credential=""
|
feed_credential=""
|
||||||
verbose=false
|
verbose=false
|
||||||
shared_runtime=false
|
runtime=""
|
||||||
runtime_id=""
|
runtime_id=""
|
||||||
override_non_versioned_files=true
|
override_non_versioned_files=true
|
||||||
|
|
||||||
|
@ -762,7 +792,18 @@ do
|
||||||
architecture="$1"
|
architecture="$1"
|
||||||
;;
|
;;
|
||||||
--shared-runtime|-[Ss]hared[Rr]untime)
|
--shared-runtime|-[Ss]hared[Rr]untime)
|
||||||
shared_runtime=true
|
say_warning "The --shared-runtime flag is obsolete and may be removed in a future version of this script. The recommended usage is to specify '--runtime dotnet'."
|
||||||
|
if [ -z "$runtime" ]; then
|
||||||
|
runtime="dotnet"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
--runtime|-[Rr]untime)
|
||||||
|
shift
|
||||||
|
runtime="$1"
|
||||||
|
if [[ "$runtime" != "dotnet" ]] && [[ "$runtime" != "aspnetcore" ]]; then
|
||||||
|
say_err "Unsupported value for --runtime: '$1'. Valid values are 'dotnet' and 'aspnetcore'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
--dry-run|-[Dd]ry[Rr]un)
|
--dry-run|-[Dd]ry[Rr]un)
|
||||||
dry_run=true
|
dry_run=true
|
||||||
|
@ -790,7 +831,6 @@ do
|
||||||
runtime_id="$1"
|
runtime_id="$1"
|
||||||
;;
|
;;
|
||||||
--skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles)
|
--skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles)
|
||||||
shift
|
|
||||||
override_non_versioned_files=false
|
override_non_versioned_files=false
|
||||||
;;
|
;;
|
||||||
-?|--?|-h|--help|-[Hh]elp)
|
-?|--?|-h|--help|-[Hh]elp)
|
||||||
|
@ -823,8 +863,11 @@ do
|
||||||
echo " -InstallDir"
|
echo " -InstallDir"
|
||||||
echo " --architecture <ARCHITECTURE> Architecture of .NET Tools. Currently only x64 is supported."
|
echo " --architecture <ARCHITECTURE> Architecture of .NET Tools. Currently only x64 is supported."
|
||||||
echo " --arch,-Architecture,-Arch"
|
echo " --arch,-Architecture,-Arch"
|
||||||
echo " --shared-runtime Installs just the shared runtime bits, not the entire SDK."
|
echo " --runtime <RUNTIME> Installs a shared runtime only, without the SDK."
|
||||||
echo " -SharedRuntime"
|
echo " -Runtime"
|
||||||
|
echo " Possible values:"
|
||||||
|
echo " - dotnet - the Microsoft.NETCore.App shared framework"
|
||||||
|
echo " - aspnetcore - the Microsoft.AspNetCore.All shared framework"
|
||||||
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
|
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
|
||||||
echo " -SkipNonVersionedFiles"
|
echo " -SkipNonVersionedFiles"
|
||||||
echo " --dry-run,-DryRun Do not perform installation. Display download link."
|
echo " --dry-run,-DryRun Do not perform installation. Display download link."
|
||||||
|
@ -837,6 +880,10 @@ do
|
||||||
echo " -RuntimeId"
|
echo " -RuntimeId"
|
||||||
echo " -?,--?,-h,--help,-Help Shows this help message"
|
echo " -?,--?,-h,--help,-Help Shows this help message"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "Obsolete parameters:"
|
||||||
|
echo " --shared-runtime The recommended alternative is '--runtime dotnet'."
|
||||||
|
echo " -SharedRuntime Installs just the shared runtime bits, not the entire SDK."
|
||||||
|
echo ""
|
||||||
echo "Install Location:"
|
echo "Install Location:"
|
||||||
echo " Location is chosen in following order:"
|
echo " Location is chosen in following order:"
|
||||||
echo " - --install-dir option"
|
echo " - --install-dir option"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue