@ -64,6 +64,10 @@ else
use_global_nuget_cache = ${ use_global_nuget_cache :- true }
use_global_nuget_cache = ${ use_global_nuget_cache :- true }
fi
fi
# Used when restoring .NET SDK from alternative feeds
runtime_source_feed = ${ runtime_source_feed :- '' }
runtime_source_feed_key = ${ runtime_source_feed_key :- '' }
# Resolve any symlinks in the given path.
# Resolve any symlinks in the given path.
function ResolvePath {
function ResolvePath {
local path = $1
local path = $1
@ -170,11 +174,11 @@ function InitializeDotNetCli {
function InstallDotNetSdk {
function InstallDotNetSdk {
local root = $1
local root = $1
local version = $2
local version = $2
local architecture = ""
local architecture = "unset "
if [ [ $# = = 3 ] ] ; then
if [ [ $# -ge 3 ] ] ; then
architecture = $3
architecture = $3
fi
fi
InstallDotNet " $root " " $version " $architecture
InstallDotNet " $root " " $version " $architecture 'sdk' 'false' $runtime_source_feed $runtime_source_feed_key
}
}
function InstallDotNet {
function InstallDotNet {
@ -185,50 +189,50 @@ function InstallDotNet {
local install_script = $_GetDotNetInstallScript
local install_script = $_GetDotNetInstallScript
local archArg = ''
local archArg = ''
if [ [ -n " ${ 3 :- } " ] ] ; then
if [ [ -n " ${ 3 :- } " ] ] && [ " $3 " != 'unset' ] ; then
archArg = " --architecture $3 "
archArg = " --architecture $3 "
fi
fi
local runtimeArg = ''
local runtimeArg = ''
if [ [ -n " ${ 4 :- } " ] ] ; then
if [ [ -n " ${ 4 :- } " ] ] && [ " $4 " != 'sdk' ] ; then
runtimeArg = " --runtime $4 "
runtimeArg = " --runtime $4 "
fi
fi
local skipNonVersionedFilesArg = ""
local skipNonVersionedFilesArg = ""
if [ [ " $# " -ge "5" ] ] ; then
if [ [ " $# " -ge "5" ] ] && [ [ " $5 " != 'false' ] ] ; then
skipNonVersionedFilesArg = "--skip-non-versioned-files"
skipNonVersionedFilesArg = "--skip-non-versioned-files"
fi
fi
bash " $install_script " --version $version --install-dir " $root " $archArg $runtimeArg $skipNonVersionedFilesArg || {
bash " $install_script " --version $version --install-dir " $root " $archArg $runtimeArg $skipNonVersionedFilesArg || {
local exit_code = $?
local exit_code = $?
Write-PipelineTelemetryError -category 'InitializeToolset' " Failed to install dotnet SDK from public location (exit code ' $exit_code '). "
echo " Failed to install dotnet SDK from public location (exit code ' $exit_code '). "
if [ [ -n " $runtimeArg " ] ] ; then
local runtimeSourceFeed = ''
local runtimeSourceFeed = ''
if [ [ -n " ${ 6 :- } " ] ] ; then
if [ [ -n " ${ 6 :- } " ] ] ; then
runtimeSourceFeed = " --azure-feed $6 "
runtimeSourceFeed = " --azure-feed $6 "
fi
fi
local runtimeSourceFeedKey = ''
local runtimeSourceFeedKey = ''
if [ [ -n " ${ 7 :- } " ] ] ; then
if [ [ -n " ${ 7 :- } " ] ] ; then
# The 'base64' binary on alpine uses '-d' and doesn't support '--decode'
# The 'base64' binary on alpine uses '-d' and doesn't support '--decode'
# '-d'. To work around this, do a simple detection and switch the parameter
# '-d'. To work around this, do a simple detection and switch the parameter
# accordingly.
# accordingly.
decodeArg = "--decode"
decodeArg = "--decode"
if base64 --help 2>& 1 | grep -q "BusyBox" ; then
if base64 --help 2>& 1 | grep -q "BusyBox" ; then
decodeArg = "-d"
decodeArg = "-d"
fi
decodedFeedKey = ` echo $7 | base64 $decodeArg `
runtimeSourceFeedKey = " --feed-credential $decodedFeedKey "
fi
fi
decodedFeedKey = ` echo $7 | base64 $decodeArg `
runtimeSourceFeedKey = " --feed-credential $decodedFeedKey "
fi
if [ [ -n " $runtimeSourceFeed " || -n " $runtimeSourceFeedKey " ] ] ; then
if [ [ -n " $runtimeSourceFeed " || -n " $runtimeSourceFeedKey " ] ] ; then
bash " $install_script " --version $version --install-dir " $root " $archArg $runtimeArg $skipNonVersionedFilesArg $runtimeSourceFeed $runtimeSourceFeedKey || {
bash " $install_script " --version $version --install-dir " $root " $archArg $runtimeArg $skipNonVersionedFilesArg $runtimeSourceFeed $runtimeSourceFeedKey || {
local exit_code = $?
local exit_code = $?
Write-PipelineTelemetryError -category 'InitializeToolset' " Failed to install dotnet SDK from custom location ' $runtimeSourceFeed ' (exit code ' $exit_code '). "
Write-PipelineTelemetryError -category 'InitializeToolset' " Failed to install dotnet SDK from custom location ' $runtimeSourceFeed ' (exit code ' $exit_code '). "
ExitWithExitCode $exit_code
}
else
ExitWithExitCode $exit_code
ExitWithExitCode $exit_code
}
else
if [ [ $exit_code != 0 ] ] ; then
Write-PipelineTelemetryError -category 'InitializeToolset' " Failed to install dotnet SDK from public location (exit code ' $exit_code '). "
fi
fi
ExitWithExitCode $exit_code
fi
fi
}
}
}
}