Skip to content

Commit bad5399

Browse files
sanjuyadav24Sanju Yadav
and
Sanju Yadav
authored
Update dotnet download Installer Url and Added a fallback check (#20752)
* Update dotnet download Url and Added a fallback check * code review changes for changing dotnet installer link * code review changes for changing dotnet installer link --------- Co-authored-by: Sanju Yadav <[email protected]>
1 parent cc4095f commit bad5399

25 files changed

+210
-74
lines changed

Tasks/DotNetCoreInstallerV0/externals/install-dotnet.ps1

+20-8
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
.PARAMETER Verbose
4848
Displays diagnostics information.
4949
.PARAMETER AzureFeed
50-
Default: https://dotnetcli.azureedge.net/dotnet
50+
Default: https://builds.dotnet.microsoft.com/dotnet
5151
This parameter typically is not changed by the user.
5252
It allows to change URL for the Azure feed used by this installer.
5353
.PARAMETER UncachedFeed
@@ -68,7 +68,8 @@ param(
6868
[switch]$SharedRuntime,
6969
[switch]$DryRun,
7070
[switch]$NoPath,
71-
[string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet",
71+
[string]$AzureFeed="https://builds.dotnet.microsoft.com/dotnet",
72+
[string]$FallbackAzureFeed="https://dotnetcli.azureedge.net/dotnet",
7273
[string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet",
7374
[string]$ProxyAddress,
7475
[switch]$ProxyUseDefaultCredentials
@@ -446,12 +447,14 @@ function Prepend-Sdk-InstallRoot-To-Path([string]$InstallRoot, [string]$BinFolde
446447
$CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture
447448
$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version
448449
$DownloadLink = Get-Download-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
450+
$FallbackDownloadLink = Get-Download-Link -AzureFeed $FallbackAzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
449451
$LegacyDownloadLink = Get-LegacyDownload-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
450452

451453
if ($DryRun) {
452454
Say "Payload URLs:"
453455
Say "Primary - $DownloadLink"
454456
Say "Legacy - $LegacyDownloadLink"
457+
Say "Fallback - $FallbackDownloadLink"
455458
Say "Repeatable invocation: .\$($MyInvocation.MyCommand) -Version $SpecificVersion -Channel $Channel -Architecture $CLIArchitecture -InstallDir $InstallDir"
456459
exit 0
457460
}
@@ -484,12 +487,21 @@ try {
484487
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
485488
}
486489
catch {
487-
Say "Cannot download: $DownloadLink"
488-
$DownloadLink = $LegacyDownloadLink
489-
$ZipPath = [System.IO.Path]::GetTempFileName()
490-
Say-Verbose "Legacy zip path: $ZipPath"
491-
Say "Downloading legacy link: $DownloadLink"
492-
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
490+
try {
491+
Say "Cannot download: $DownloadLink"
492+
$DownloadLink = $FallbackDownloadLink
493+
$ZipPath = [System.IO.Path]::GetTempFileName()
494+
Say-Verbose "Fallabck zip path: $ZipPath"
495+
Say "Downloading fallback link: $FallbackDownloadLink"
496+
DownloadFile -Uri $FallbackDownloadLink -OutPath $ZipPath
497+
} catch {
498+
Say "Cannot download: $FallbackDownloadLink"
499+
$DownloadLink = $LegacyDownloadLink
500+
$ZipPath = [System.IO.Path]::GetTempFileName()
501+
Say-Verbose "Legacy zip path: $ZipPath"
502+
Say "Downloading legacy link: $DownloadLink"
503+
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
504+
}
493505
}
494506

495507
Say "Extracting zip from $DownloadLink"

Tasks/DotNetCoreInstallerV0/externals/install-dotnet.sh

+19-2
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ calculate_vars() {
628628
download_link=$(construct_download_link $azure_feed $channel $normalized_architecture $specific_version)
629629
say_verbose "download_link=$download_link"
630630

631+
fallback_download_link=$(construct_download_link $fallback_azure_feed $channel $normalized_architecture $specific_version)
632+
say_verbose "fallback_download_link=$fallback_download_link"
633+
631634
legacy_download_link=$(construct_legacy_download_link $azure_feed $channel $normalized_architecture $specific_version) || valid_legacy_download_link=false
632635

633636
if [ "$valid_legacy_download_link" = true ]; then
@@ -643,6 +646,7 @@ calculate_vars() {
643646
install_dotnet() {
644647
eval $invocation
645648
local download_failed=false
649+
local fallback_download_failed=false
646650

647651
if is_dotnet_package_installed $install_root "sdk" $specific_version; then
648652
say ".NET SDK version $specific_version is already installed."
@@ -656,8 +660,20 @@ install_dotnet() {
656660
say "Downloading link: $download_link"
657661
download "$download_link" $zip_path || download_failed=true
658662

663+
say_verbose "download_failed: $download_failed"
664+
665+
if [ "$download_failed" = true ]; then
666+
say "Cannot download: $download_link"
667+
download_link=$fallback_download_link
668+
zip_path=$(mktemp $temporary_file_template)
669+
say_verbose "Fallback zip path: $zip_path"
670+
say "Downloading fallback link: $download_link"
671+
download "$download_link" $zip_path || fallback_download_failed=true
672+
fi
673+
674+
say_verbose "valid_legacy_download_link: $valid_legacy_download_link"
659675
# if the download fails, download the legacy_download_link
660-
if [ "$download_failed" = true ] && [ "$valid_legacy_download_link" = true ]; then
676+
if [ "$fallback_download_failed" = true ] && [ "$valid_legacy_download_link" = true ]; then
661677
say "Cannot download: $download_link"
662678
download_link=$legacy_download_link
663679
zip_path=$(mktemp $temporary_file_template)
@@ -682,7 +698,8 @@ install_dir="<auto>"
682698
architecture="<auto>"
683699
dry_run=false
684700
no_path=false
685-
azure_feed="https://dotnetcli.azureedge.net/dotnet"
701+
fallback_azure_feed="https://dotnetcli.azureedge.net/dotnet"
702+
azure_feed="https://builds.dotnet.microsoft.com/dotnet"
686703
uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet"
687704
verbose=false
688705
shared_runtime=false

Tasks/DotNetCoreInstallerV0/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 247,
16+
"Minor": 250,
1717
"Patch": 0
1818
},
1919
"satisfies": [

Tasks/DotNetCoreInstallerV0/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 247,
16+
"Minor": 250,
1717
"Patch": 0
1818
},
1919
"satisfies": [

Tasks/UseDotNetV2/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 2,
16-
"Minor": 248,
16+
"Minor": 250,
1717
"Patch": 0
1818
},
1919
"satisfies": [

Tasks/UseDotNetV2/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 2,
16-
"Minor": 248,
16+
"Minor": 250,
1717
"Patch": 0
1818
},
1919
"satisfies": [

Tasks/UseDotNetV2/versioninstaller.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ export class VersionInstaller {
3838
var downloadPath = await toolLib.downloadToolWithRetries(downloadUrl)
3939
}
4040
catch (ex) {
41-
tl.warning(tl.loc("CouldNotDownload", downloadUrl, ex));
42-
let fallBackUrl = `https://dotnetcli.azureedge.net/dotnet/${this.packageType === "runtime" ? "Runtime" : "Sdk"}/${version}/${downloadUrl.substring(downloadUrl.lastIndexOf('/') + 1)}`;
43-
console.log("Using fallback url for download: " + fallBackUrl);
44-
var downloadPath = await toolLib.downloadToolWithRetries(fallBackUrl)
41+
let feedFallbackUrl = "https://builds.dotnet.microsoft.com/dotnet";
42+
try {
43+
tl.warning(tl.loc("CouldNotDownload", downloadUrl, ex));
44+
var downloadPath = await this.downloadFromFallbackUrl(feedFallbackUrl, this.packageType, version, downloadUrl);
45+
} catch(ex) {
46+
tl.warning(tl.loc("CouldNotDownload", feedFallbackUrl, ex));
47+
var downloadPath = await this.downloadFromFallbackUrl("https://dotnetcli.azureedge.net/dotnet", this.packageType, version, downloadUrl);
48+
}
4549
}
4650

4751
// Extract
@@ -176,6 +180,13 @@ export class VersionInstaller {
176180
throw tl.loc("FileNameNotCorrectCompleteFileName", name);
177181
}
178182

183+
private async downloadFromFallbackUrl(fallBackUrl: string, packageType: string, version: string, downloadUrl: string) : Promise<string> {
184+
let url = `${fallBackUrl}/${packageType === "runtime" ? "Runtime" : "Sdk"}/${version}/${downloadUrl.substring(downloadUrl.lastIndexOf('/') + 1)}`;
185+
console.log("Using fallback url for download: " + url);
186+
var downloadPath = await toolLib.downloadToolWithRetries(url)
187+
return downloadPath;
188+
}
189+
179190
private packageType: string;
180191
private installationPath: string;
181192
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|0.247.0
2-
Node20_229_3|0.247.1
1+
Default|0.250.0
2+
Node20_229_3|0.250.1

_generated/DotNetCoreInstallerV0/externals/install-dotnet.ps1

+20-8
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
.PARAMETER Verbose
4848
Displays diagnostics information.
4949
.PARAMETER AzureFeed
50-
Default: https://dotnetcli.azureedge.net/dotnet
50+
Default: https://builds.dotnet.microsoft.com/dotnet
5151
This parameter typically is not changed by the user.
5252
It allows to change URL for the Azure feed used by this installer.
5353
.PARAMETER UncachedFeed
@@ -68,7 +68,8 @@ param(
6868
[switch]$SharedRuntime,
6969
[switch]$DryRun,
7070
[switch]$NoPath,
71-
[string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet",
71+
[string]$AzureFeed="https://builds.dotnet.microsoft.com/dotnet",
72+
[string]$FallbackAzureFeed="https://dotnetcli.azureedge.net/dotnet",
7273
[string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet",
7374
[string]$ProxyAddress,
7475
[switch]$ProxyUseDefaultCredentials
@@ -446,12 +447,14 @@ function Prepend-Sdk-InstallRoot-To-Path([string]$InstallRoot, [string]$BinFolde
446447
$CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture
447448
$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version
448449
$DownloadLink = Get-Download-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
450+
$FallbackDownloadLink = Get-Download-Link -AzureFeed $FallbackAzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
449451
$LegacyDownloadLink = Get-LegacyDownload-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
450452

451453
if ($DryRun) {
452454
Say "Payload URLs:"
453455
Say "Primary - $DownloadLink"
454456
Say "Legacy - $LegacyDownloadLink"
457+
Say "Fallback - $FallbackDownloadLink"
455458
Say "Repeatable invocation: .\$($MyInvocation.MyCommand) -Version $SpecificVersion -Channel $Channel -Architecture $CLIArchitecture -InstallDir $InstallDir"
456459
exit 0
457460
}
@@ -484,12 +487,21 @@ try {
484487
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
485488
}
486489
catch {
487-
Say "Cannot download: $DownloadLink"
488-
$DownloadLink = $LegacyDownloadLink
489-
$ZipPath = [System.IO.Path]::GetTempFileName()
490-
Say-Verbose "Legacy zip path: $ZipPath"
491-
Say "Downloading legacy link: $DownloadLink"
492-
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
490+
try {
491+
Say "Cannot download: $DownloadLink"
492+
$DownloadLink = $FallbackDownloadLink
493+
$ZipPath = [System.IO.Path]::GetTempFileName()
494+
Say-Verbose "Fallabck zip path: $ZipPath"
495+
Say "Downloading fallback link: $FallbackDownloadLink"
496+
DownloadFile -Uri $FallbackDownloadLink -OutPath $ZipPath
497+
} catch {
498+
Say "Cannot download: $FallbackDownloadLink"
499+
$DownloadLink = $LegacyDownloadLink
500+
$ZipPath = [System.IO.Path]::GetTempFileName()
501+
Say-Verbose "Legacy zip path: $ZipPath"
502+
Say "Downloading legacy link: $DownloadLink"
503+
DownloadFile -Uri $DownloadLink -OutPath $ZipPath
504+
}
493505
}
494506

495507
Say "Extracting zip from $DownloadLink"

_generated/DotNetCoreInstallerV0/externals/install-dotnet.sh

+19-2
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ calculate_vars() {
628628
download_link=$(construct_download_link $azure_feed $channel $normalized_architecture $specific_version)
629629
say_verbose "download_link=$download_link"
630630

631+
fallback_download_link=$(construct_download_link $fallback_azure_feed $channel $normalized_architecture $specific_version)
632+
say_verbose "fallback_download_link=$fallback_download_link"
633+
631634
legacy_download_link=$(construct_legacy_download_link $azure_feed $channel $normalized_architecture $specific_version) || valid_legacy_download_link=false
632635

633636
if [ "$valid_legacy_download_link" = true ]; then
@@ -643,6 +646,7 @@ calculate_vars() {
643646
install_dotnet() {
644647
eval $invocation
645648
local download_failed=false
649+
local fallback_download_failed=false
646650

647651
if is_dotnet_package_installed $install_root "sdk" $specific_version; then
648652
say ".NET SDK version $specific_version is already installed."
@@ -656,8 +660,20 @@ install_dotnet() {
656660
say "Downloading link: $download_link"
657661
download "$download_link" $zip_path || download_failed=true
658662

663+
say_verbose "download_failed: $download_failed"
664+
665+
if [ "$download_failed" = true ]; then
666+
say "Cannot download: $download_link"
667+
download_link=$fallback_download_link
668+
zip_path=$(mktemp $temporary_file_template)
669+
say_verbose "Fallback zip path: $zip_path"
670+
say "Downloading fallback link: $download_link"
671+
download "$download_link" $zip_path || fallback_download_failed=true
672+
fi
673+
674+
say_verbose "valid_legacy_download_link: $valid_legacy_download_link"
659675
# if the download fails, download the legacy_download_link
660-
if [ "$download_failed" = true ] && [ "$valid_legacy_download_link" = true ]; then
676+
if [ "$fallback_download_failed" = true ] && [ "$valid_legacy_download_link" = true ]; then
661677
say "Cannot download: $download_link"
662678
download_link=$legacy_download_link
663679
zip_path=$(mktemp $temporary_file_template)
@@ -682,7 +698,8 @@ install_dir="<auto>"
682698
architecture="<auto>"
683699
dry_run=false
684700
no_path=false
685-
azure_feed="https://dotnetcli.azureedge.net/dotnet"
701+
fallback_azure_feed="https://dotnetcli.azureedge.net/dotnet"
702+
azure_feed="https://builds.dotnet.microsoft.com/dotnet"
686703
uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet"
687704
verbose=false
688705
shared_runtime=false

_generated/DotNetCoreInstallerV0/task.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 247,
16+
"Minor": 250,
1717
"Patch": 0
1818
},
1919
"satisfies": [
@@ -80,7 +80,8 @@
8080
"UpdateToNewerVersion": "Kindly upgrade to new major version of this task 'Use .NET Core (2.*)' for installing newer versions of .NET Core. '0.*' task version might not be able to download newer .NET core versions. To know more about 'Use Dot Net (2.*)', refer https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/dotnet-core-tool-installer?view=azure-devops."
8181
},
8282
"_buildConfigMapping": {
83-
"Default": "0.247.0",
84-
"Node20_229_3": "0.247.1"
83+
"Default": "0.250.0",
84+
"LocalPackages": "0.249.4",
85+
"Node20_229_3": "0.250.1"
8586
}
8687
}

_generated/DotNetCoreInstallerV0/task.loc.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 0,
16-
"Minor": 247,
16+
"Minor": 250,
1717
"Patch": 0
1818
},
1919
"satisfies": [
@@ -80,7 +80,8 @@
8080
"UpdateToNewerVersion": "ms-resource:loc.messages.UpdateToNewerVersion"
8181
},
8282
"_buildConfigMapping": {
83-
"Default": "0.247.0",
84-
"Node20_229_3": "0.247.1"
83+
"Default": "0.250.0",
84+
"LocalPackages": "0.249.4",
85+
"Node20_229_3": "0.250.1"
8586
}
8687
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
scripts-prepend-node-path=true
2+
3+
registry=https://pkgs.dev.azure.com/mseng/PipelineTools/_packaging/PipelineTools_PublicPackages/npm/registry/
4+
5+
always-auth=true

0 commit comments

Comments
 (0)