Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit fd04fdd

Browse files
author
Nate McMaster
committed
Add parameter to dotnet-install to support pulling from private blob feeds
1 parent c4153be commit fd04fdd

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

scripts/obtain/dotnet-install.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@
4949
.PARAMETER AzureFeed
5050
Default: https://dotnetcli.azureedge.net/dotnet
5151
This parameter typically is not changed by the user.
52-
It allows to change URL for the Azure feed used by this installer.
52+
It allows changing the URL for the Azure feed used by this installer.
5353
.PARAMETER UncachedFeed
5454
This parameter typically is not changed by the user.
55-
It allows to change URL for the Uncached feed used by this installer.
55+
It allows changing the URL for the Uncached feed used by this installer.
56+
.PARAMETER FeedCredential
57+
Used as a query string to append to the Azure feed.
58+
It allows changing the URL to use non-public blob storage accounts.
5659
.PARAMETER ProxyAddress
5760
If set, the installer will use the proxy when making web requests
5861
.PARAMETER ProxyUseDefaultCredentials
@@ -73,6 +76,7 @@ param(
7376
[switch]$NoPath,
7477
[string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet",
7578
[string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet",
79+
[string]$FeedCredential,
7680
[string]$ProxyAddress,
7781
[switch]$ProxyUseDefaultCredentials,
7882
[switch]$SkipNonVersionedFiles
@@ -199,8 +203,10 @@ function GetHTTPResponse([Uri] $Uri)
199203
# Default timeout for HttpClient is 100s. For a 50 MB download this assumes 500 KB/s average, any less will time out
200204
# 10 minutes allows it to work over much slower connections.
201205
$HttpClient.Timeout = New-TimeSpan -Minutes 10
202-
$Response = $HttpClient.GetAsync($Uri).Result
206+
$ActualUri = if (($Uri -like "$AzureFeed*") -or ($Uri -like "$UncachedFeed*")) { "${Uri}${FeedCredential}" } else { $Uri }
207+
$Response = $HttpClient.GetAsync($ActualUri).Result
203208
if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode))) {
209+
# The feed credential is potential sensitive info. Do not log ActualUri to console output.
204210
$ErrorMsg = "Failed to download $Uri."
205211
if ($Response -ne $null) {
206212
$ErrorMsg += " $Response"

scripts/obtain/dotnet-install.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ downloadcurl() {
618618
local remote_path="$1"
619619
local out_path="${2:-}"
620620

621+
# Append feed_credential as late as possible before calling curl to avoid logging feed_credential
622+
if [[ "$remote_path" == "$azure_feed"* ]] || [[ "$remote_path" == "$uncached_feed"* ]]; then
623+
remote_path="${remote_path}${feed_credential}"
624+
fi
625+
621626
local failed=false
622627
if [ -z "$out_path" ]; then
623628
curl --retry 10 -sSL -f --create-dirs "$remote_path" || failed=true
@@ -636,6 +641,11 @@ downloadwget() {
636641
local remote_path="$1"
637642
local out_path="${2:-}"
638643

644+
# Append feed_credential as late as possible before calling wget to avoid logging feed_credential
645+
if [[ "$remote_path" == "$azure_feed"* ]] || [[ "$remote_path" == "$uncached_feed"* ]]; then
646+
remote_path="${remote_path}${feed_credential}"
647+
fi
648+
639649
local failed=false
640650
if [ -z "$out_path" ]; then
641651
wget -q --tries 10 -O - "$remote_path" || failed=true
@@ -725,6 +735,7 @@ dry_run=false
725735
no_path=false
726736
azure_feed="https://dotnetcli.azureedge.net/dotnet"
727737
uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet"
738+
feed_credential=""
728739
verbose=false
729740
shared_runtime=false
730741
runtime_id=""
@@ -770,6 +781,10 @@ do
770781
shift
771782
uncached_feed="$1"
772783
;;
784+
--feed-credential|-[Ff]eed[Cc]redential)
785+
shift
786+
feed_credential="$1"
787+
;;
773788
--runtime-id|-[Rr]untime[Ii]d)
774789
shift
775790
runtime_id="$1"
@@ -804,22 +819,23 @@ do
804819
echo " coherent applies only to SDK downloads"
805820
echo " - 3-part version in a format A.B.C - represents specific version of build"
806821
echo " examples: 2.0.0-preview2-006120; 1.1.0"
807-
echo " -i,--install-dir <DIR> Install under specified location (see Install Location below)"
822+
echo " -i,--install-dir <DIR> Install under specified location (see Install Location below)"
808823
echo " -InstallDir"
809-
echo " --architecture <ARCHITECTURE> Architecture of .NET Tools. Currently only x64 is supported."
824+
echo " --architecture <ARCHITECTURE> Architecture of .NET Tools. Currently only x64 is supported."
810825
echo " --arch,-Architecture,-Arch"
811-
echo " --shared-runtime Installs just the shared runtime bits, not the entire SDK."
826+
echo " --shared-runtime Installs just the shared runtime bits, not the entire SDK."
812827
echo " -SharedRuntime"
813-
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
828+
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
814829
echo " -SkipNonVersionedFiles"
815-
echo " --dry-run,-DryRun Do not perform installation. Display download link."
816-
echo " --no-path, -NoPath Do not set PATH for the current process."
817-
echo " --verbose,-Verbose Display diagnostics information."
818-
echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user."
819-
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user."
820-
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
830+
echo " --dry-run,-DryRun Do not perform installation. Display download link."
831+
echo " --no-path, -NoPath Do not set PATH for the current process."
832+
echo " --verbose,-Verbose Display diagnostics information."
833+
echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user."
834+
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user."
835+
echo " --feed-credential,-FeedCredential Azure feed shared access token. This parameter typically is not specified."
836+
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
821837
echo " -RuntimeId"
822-
echo " -?,--?,-h,--help,-Help Shows this help message"
838+
echo " -?,--?,-h,--help,-Help Shows this help message"
823839
echo ""
824840
echo "Install Location:"
825841
echo " Location is chosen in following order:"

0 commit comments

Comments
 (0)