@@ -188,28 +188,29 @@ function InstallDotNet {
188188 GetDotNetInstallScript " $root "
189189 local install_script=$_GetDotNetInstallScript
190190
191- local archArg=' '
191+ local installParameters=(--version $version --install-dir " $root " )
192+
192193 if [[ -n " ${3:- } " ]] && [ " $3 " != ' unset' ]; then
193- archArg= " --architecture $3 "
194+ installParameters+=( --architecture $3 )
194195 fi
195- local runtimeArg=' '
196196 if [[ -n " ${4:- } " ]] && [ " $4 " != ' sdk' ]; then
197- runtimeArg= " --runtime $4 "
197+ installParameters+=( --runtime $4 )
198198 fi
199- local skipNonVersionedFilesArg=" "
200199 if [[ " $# " -ge " 5" ]] && [[ " $5 " != ' false' ]]; then
201- skipNonVersionedFilesArg= " --skip-non-versioned-files"
200+ installParameters+=( --skip-non-versioned-files)
202201 fi
203- bash " $install_script " --version $version --install-dir " $root " $archArg $runtimeArg $skipNonVersionedFilesArg || {
204- local exit_code=$?
205- echo " Failed to install dotnet SDK from public location (exit code '$exit_code ')."
206202
207- local runtimeSourceFeed= ' '
208- if [[ -n " ${6 :- } " ]] ; then
209- runtimeSourceFeed= " --azure-feed $6 "
210- fi
203+ local variations=() # list of variable names with parameter arrays in them
204+
205+ local public_location=( " ${installParameters[@]} " )
206+ variations+=(public_location)
211207
212- local runtimeSourceFeedKey=' '
208+ local dotnetbuilds=(" ${installParameters[@]} " --azure-feed " https://dotnetbuilds.azureedge.net/public" )
209+ variations+=(dotnetbuilds)
210+
211+ if [[ -n " ${6:- } " ]]; then
212+ variations+=(private_feed)
213+ local private_feed=(" ${installParameters[@]} " --azure-feed $6 )
213214 if [[ -n " ${7:- } " ]]; then
214215 # The 'base64' binary on alpine uses '-d' and doesn't support '--decode'
215216 # '-d'. To work around this, do a simple detection and switch the parameter
@@ -219,22 +220,27 @@ function InstallDotNet {
219220 decodeArg=" -d"
220221 fi
221222 decodedFeedKey=` echo $7 | base64 $decodeArg `
222- runtimeSourceFeedKey= " --feed-credential $decodedFeedKey "
223+ private_feed+=( --feed-credential $decodedFeedKey )
223224 fi
225+ fi
224226
225- if [[ -n " $runtimeSourceFeed " || -n " $runtimeSourceFeedKey " ]]; then
226- bash " $install_script " --version $version --install-dir " $root " $archArg $runtimeArg $skipNonVersionedFilesArg $runtimeSourceFeed $runtimeSourceFeedKey || {
227- local exit_code=$?
228- Write-PipelineTelemetryError -category ' InitializeToolset' " Failed to install dotnet SDK from custom location '$runtimeSourceFeed ' (exit code '$exit_code ')."
229- ExitWithExitCode $exit_code
230- }
231- else
232- if [[ $exit_code != 0 ]]; then
233- Write-PipelineTelemetryError -category ' InitializeToolset' " Failed to install dotnet SDK from public location (exit code '$exit_code ')."
234- fi
235- ExitWithExitCode $exit_code
227+ local installSuccess=0
228+ for variationName in " ${variations[@]} " ; do
229+ local name=" $variationName [@]"
230+ local variation=(" ${! name} " )
231+ echo " Attempting to install dotnet from $variationName ."
232+ bash " $install_script " " ${variation[@]} " && installSuccess=1
233+ if [[ " $installSuccess " -eq 1 ]]; then
234+ break
236235 fi
237- }
236+
237+ echo " Failed to install dotnet from $variationName ."
238+ done
239+
240+ if [[ " $installSuccess " -eq 0 ]]; then
241+ Write-PipelineTelemetryError -category ' InitializeToolset' " Failed to install dotnet SDK from any of the specified locations."
242+ ExitWithExitCode 1
243+ fi
238244}
239245
240246function with_retries {
@@ -399,13 +405,6 @@ function StopProcesses {
399405 return 0
400406}
401407
402- function TryLogClientIpAddress () {
403- echo ' Attempting to log this client' ' s IP for Azure Package feed telemetry purposes'
404- if command -v curl > /dev/null; then
405- curl -s ' http://co1.msedge.net/fdv2/diagnostics.aspx' | grep ' IP: ' || true
406- fi
407- }
408-
409408function MSBuild {
410409 local args=$@
411410 if [[ " $pipelines_log " == true ]]; then
0 commit comments