@@ -33,6 +33,7 @@ target_arch='x64'
3333configuration=' '
3434runtime_source_feed=' '
3535runtime_source_feed_key=' '
36+ init_nuget=false
3637
3738if [ " $( uname) " = " Darwin" ]; then
3839 target_os_name=' osx'
@@ -82,6 +83,8 @@ Options:
8283 --runtime-source-feed Additional feed that can be used when downloading .NET runtimes and SDKs
8384 --runtime-source-feed-key Key for feed that can be used when downloading .NET runtimes and SDKs
8485
86+ --init-nuget Run nuget --version.
87+
8588Description:
8689 This build script installs required tools and runs an MSBuild command on this repository
8790 This script can be used to invoke various targets, such as targets to produce packages
@@ -208,6 +211,9 @@ while [[ $# -gt 0 ]]; do
208211 -ci)
209212 ci=true
210213 ;;
214+ -init-nuget)
215+ init_nuget=true
216+ ;;
211217 -binarylog|-bl)
212218 binary_log=true
213219 ;;
@@ -359,6 +365,30 @@ export MSBUILDDEBUGPATH="$log_dir"
359365_tmp_restore=$restore
360366restore=true
361367
368+ if [[ " $init_nuget " == true ]]; then
369+ InitializeBuildTool
370+
371+ function RunBuildTool {
372+ " $_InitializeBuildTool " " $@ " || {
373+ local exit_code=$?
374+ # We should not Write-PipelineTaskError here because that message shows up in the build summary
375+ # The build already logged an error, that's the reason it failed. Producing an error here only adds noise.
376+ echo " Build failed with exit code $exit_code . Check errors above."
377+ if [[ " $ci " == " true" ]]; then
378+ Write-PipelineSetResult -result " Failed" -message " nuget execution failed."
379+ # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error
380+ # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error
381+ ExitWithExitCode 0
382+ else
383+ ExitWithExitCode $exit_code
384+ fi
385+ }
386+ }
387+
388+ echo ' Running dotnet nuget --version (issue: https://github.com/NuGet/Home/issues/12159#issuecomment-1278360511)'
389+ RunBuildTool " nuget" " --version"
390+ fi
391+
362392InitializeToolset
363393
364394restore=$_tmp_restore =
0 commit comments