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
73
scripts/obtain/dotnet-install.ps1
vendored
73
scripts/obtain/dotnet-install.ps1
vendored
|
@ -34,8 +34,17 @@
|
|||
Architecture of dotnet binaries to be installed.
|
||||
Possible values are: <auto>, x64 and x86
|
||||
.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
|
||||
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
|
||||
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
|
||||
|
@ -71,6 +80,9 @@ param(
|
|||
[string]$Version="Latest",
|
||||
[string]$InstallDir="<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]$DryRun,
|
||||
[switch]$NoPath,
|
||||
|
@ -88,6 +100,10 @@ $ProgressPreference="SilentlyContinue"
|
|||
|
||||
$BinFolderRelativePath=""
|
||||
|
||||
if ($SharedRuntime -and (-not $Runtime)) {
|
||||
$Runtime = "dotnet"
|
||||
}
|
||||
|
||||
# example path with regex: shared/1.0.0-beta-12345/somepath
|
||||
$VersionRegEx="/\d+\.\d+[^/]+/"
|
||||
$OverrideNonVersionedFiles = !$SkipNonVersionedFiles
|
||||
|
@ -230,9 +246,12 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Co
|
|||
Say-Invocation $MyInvocation
|
||||
|
||||
$VersionFileUrl = $null
|
||||
if ($SharedRuntime) {
|
||||
if ($Runtime -eq "dotnet") {
|
||||
$VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.version"
|
||||
}
|
||||
elseif ($Runtime) {
|
||||
$VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.$Runtime.version"
|
||||
}
|
||||
else {
|
||||
if ($Coherent) {
|
||||
$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) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
if ($SharedRuntime) {
|
||||
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-runtime-$SpecificVersion-win-$CLIArchitecture.zip"
|
||||
if ($Runtime) {
|
||||
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/$Runtime-runtime-$SpecificVersion-win-$CLIArchitecture.zip"
|
||||
}
|
||||
else {
|
||||
$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) {
|
||||
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"
|
||||
}
|
||||
else {
|
||||
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip"
|
||||
return $null
|
||||
}
|
||||
|
||||
Say-Verbose "Constructed legacy payload URL: $PayloadURL"
|
||||
|
@ -465,7 +487,9 @@ $LegacyDownloadLink = Get-LegacyDownload-Link -AzureFeed $AzureFeed -SpecificVer
|
|||
if ($DryRun) {
|
||||
Say "Payload URLs:"
|
||||
Say "Primary - $DownloadLink"
|
||||
Say "Legacy - $LegacyDownloadLink"
|
||||
if ($LegacyDownloadLink) {
|
||||
Say "Legacy - $LegacyDownloadLink"
|
||||
}
|
||||
Say "Repeatable invocation: .\$($MyInvocation.Line)"
|
||||
exit 0
|
||||
}
|
||||
|
@ -473,10 +497,22 @@ if ($DryRun) {
|
|||
$InstallRoot = Resolve-Installation-Path $InstallDir
|
||||
Say-Verbose "InstallRoot: $InstallRoot"
|
||||
|
||||
$IsSdkInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage "sdk" -SpecificVersion $SpecificVersion
|
||||
Say-Verbose ".NET SDK installed? $IsSdkInstalled"
|
||||
if ($IsSdkInstalled) {
|
||||
Say ".NET SDK version $SpecificVersion is already installed."
|
||||
if ($Runtime -eq "dotnet") {
|
||||
$assetName = ".NET Core Runtime"
|
||||
$dotnetPackageRelativePath = "shared\Microsoft.NETCore.App"
|
||||
}
|
||||
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
|
||||
exit 0
|
||||
}
|
||||
|
@ -498,11 +534,16 @@ try {
|
|||
}
|
||||
catch {
|
||||
Say "Cannot download: $DownloadLink"
|
||||
$DownloadLink = $LegacyDownloadLink
|
||||
$ZipPath = [System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
|
||||
Say-Verbose "Legacy zip path: $ZipPath"
|
||||
Say "Downloading legacy link: $DownloadLink"
|
||||
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
|
||||
if ($LegacyDownloadLink) {
|
||||
$DownloadLink = $LegacyDownloadLink
|
||||
$ZipPath = [System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
|
||||
Say-Verbose "Legacy zip path: $ZipPath"
|
||||
Say "Downloading legacy link: $DownloadLink"
|
||||
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
|
||||
}
|
||||
else {
|
||||
throw "Could not download $assetName version $SpecificVersion"
|
||||
}
|
||||
}
|
||||
|
||||
Say "Extracting zip from $DownloadLink"
|
||||
|
|
83
scripts/obtain/dotnet-install.sh
vendored
83
scripts/obtain/dotnet-install.sh
vendored
|
@ -39,6 +39,10 @@ if [ -t 1 ] && command -v tput > /dev/null; then
|
|||
fi
|
||||
fi
|
||||
|
||||
say_warning() {
|
||||
printf "%b\n" "${yellow:-}dotnet_install: Warning: $1${normal:-}"
|
||||
}
|
||||
|
||||
say_err() {
|
||||
printf "%b\n" "${red:-}dotnet_install: Error: $1${normal:-}" >&2
|
||||
}
|
||||
|
@ -384,8 +388,10 @@ get_latest_version_info() {
|
|||
local coherent="$4"
|
||||
|
||||
local version_file_url=null
|
||||
if [ "$shared_runtime" = true ]; then
|
||||
if [[ "$runtime" == "dotnet" ]]; then
|
||||
version_file_url="$uncached_feed/Runtime/$channel/latest.version"
|
||||
elif [ ! -z "$runtime" ]; then
|
||||
version_file_url="$uncached_feed/Runtime/$channel/latest.$runtime.version"
|
||||
else
|
||||
if [ "$coherent" = true ]; then
|
||||
version_file_url="$uncached_feed/Sdk/$channel/latest.coherent.version"
|
||||
|
@ -451,8 +457,8 @@ construct_download_link() {
|
|||
osname="$(get_current_os_name)" || return 1
|
||||
|
||||
local download_link=null
|
||||
if [ "$shared_runtime" = true ]; then
|
||||
download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_version-$osname-$normalized_architecture.tar.gz"
|
||||
if [ ! -z "$runtime" ]; then
|
||||
download_link="$azure_feed/Runtime/$specific_version/$runtime-runtime-$specific_version-$osname-$normalized_architecture.tar.gz"
|
||||
else
|
||||
download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_version-$osname-$normalized_architecture.tar.gz"
|
||||
fi
|
||||
|
@ -478,10 +484,12 @@ construct_legacy_download_link() {
|
|||
distro_specific_osname="$(get_legacy_os_name)" || return 1
|
||||
|
||||
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"
|
||||
else
|
||||
elif [ -z "$runtime" ]; then
|
||||
legacy_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$legacy_download_link"
|
||||
|
@ -691,9 +699,22 @@ calculate_vars() {
|
|||
install_dotnet() {
|
||||
eval $invocation
|
||||
local download_failed=false
|
||||
local asset_name=''
|
||||
local asset_relative_path=''
|
||||
|
||||
if is_dotnet_package_installed "$install_root" "sdk" "$specific_version"; then
|
||||
say ".NET SDK version $specific_version is already installed."
|
||||
if [[ "$runtime" == "dotnet" ]]; then
|
||||
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
|
||||
fi
|
||||
|
||||
|
@ -708,13 +729,22 @@ install_dotnet() {
|
|||
download "$download_link" "$zip_path" 2>&1 || download_failed=true
|
||||
|
||||
# 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"
|
||||
download_link="$legacy_download_link"
|
||||
zip_path="$(mktemp "$temporary_file_template")"
|
||||
say_verbose "Legacy zip path: $zip_path"
|
||||
say "Downloading legacy link: $download_link"
|
||||
download "$download_link" "$zip_path"
|
||||
|
||||
if [ "$valid_legacy_download_link" = true ]; then
|
||||
download_failed=false
|
||||
download_link="$legacy_download_link"
|
||||
zip_path="$(mktemp "$temporary_file_template")"
|
||||
say_verbose "Legacy zip path: $zip_path"
|
||||
say "Downloading legacy link: $download_link"
|
||||
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
|
||||
|
||||
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"
|
||||
feed_credential=""
|
||||
verbose=false
|
||||
shared_runtime=false
|
||||
runtime=""
|
||||
runtime_id=""
|
||||
override_non_versioned_files=true
|
||||
|
||||
|
@ -762,7 +792,18 @@ do
|
|||
architecture="$1"
|
||||
;;
|
||||
--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=true
|
||||
|
@ -790,7 +831,6 @@ do
|
|||
runtime_id="$1"
|
||||
;;
|
||||
--skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles)
|
||||
shift
|
||||
override_non_versioned_files=false
|
||||
;;
|
||||
-?|--?|-h|--help|-[Hh]elp)
|
||||
|
@ -823,8 +863,11 @@ do
|
|||
echo " -InstallDir"
|
||||
echo " --architecture <ARCHITECTURE> Architecture of .NET Tools. Currently only x64 is supported."
|
||||
echo " --arch,-Architecture,-Arch"
|
||||
echo " --shared-runtime Installs just the shared runtime bits, not the entire SDK."
|
||||
echo " -SharedRuntime"
|
||||
echo " --runtime <RUNTIME> Installs a shared runtime only, without the SDK."
|
||||
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 " -SkipNonVersionedFiles"
|
||||
echo " --dry-run,-DryRun Do not perform installation. Display download link."
|
||||
|
@ -837,6 +880,10 @@ do
|
|||
echo " -RuntimeId"
|
||||
echo " -?,--?,-h,--help,-Help Shows this help message"
|
||||
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 " Location is chosen in following order:"
|
||||
echo " - --install-dir option"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue