diff --git a/build-tools/automation/yaml-templates/variables.yaml b/build-tools/automation/yaml-templates/variables.yaml index 27bcf5d0ca5..1bbe24740be 100644 --- a/build-tools/automation/yaml-templates/variables.yaml +++ b/build-tools/automation/yaml-templates/variables.yaml @@ -74,3 +74,9 @@ variables: value: true - name: DOTNET_SYSTEM_NET_SECURITY_NOREVOCATIONCHECKBYDEFAULT value: true +- name: DOTNET_CLI_TELEMETRY_OPTOUT + value: true +- name: DOTNET_NOLOGO + value: true +- name: DOTNET_GENERATE_ASPNET_CERTIFICATE + value: false diff --git a/build-tools/xaprepare/xaprepare/Application/ProcessRunner.cs b/build-tools/xaprepare/xaprepare/Application/ProcessRunner.cs index b225ddd897a..db4f11f7675 100644 --- a/build-tools/xaprepare/xaprepare/Application/ProcessRunner.cs +++ b/build-tools/xaprepare/xaprepare/Application/ProcessRunner.cs @@ -290,7 +290,7 @@ public bool Run () if (!exited) { Log.ErrorLine ($"Process '{FullCommandLine}' timed out after {ProcessTimeout}"); ErrorReason = ErrorReasonCode.ExecutionTimedOut; - process.Kill (); + process.Kill (entireProcessTree: true); } // See: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.waitforexit?view=netframework-4.7.2#System_Diagnostics_Process_WaitForExit) diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs index 4323ff2f8fc..c5896a83c69 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs @@ -41,14 +41,34 @@ protected override async Task Execute (Context context) // Install runtime packs associated with the SDK previously installed. var packageDownloadProj = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "build-tools", "xaprepare", "xaprepare", "package-download.proj"); - var logPath = Path.Combine (Configurables.Paths.BuildBinDir, $"msbuild-{context.BuildTimeStamp}-download-runtime-packs.binlog"); - var restoreArgs = new string [] { "restore", - ProcessRunner.QuoteArgument (packageDownloadProj), - "--configfile", Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "NuGet.config"), - ProcessRunner.QuoteArgument ($"-bl:{logPath}"), - }; - if (!Utilities.RunCommand (Configurables.Paths.DotNetPreviewTool, restoreArgs)) { - Log.ErrorLine ($"Failed to restore runtime packs using '{packageDownloadProj}'."); + var logPathBase = Path.Combine (Configurables.Paths.BuildBinDir, $"msbuild-{context.BuildTimeStamp}-download-runtime-packs"); + + const int maxAttempts = 3; + const int initialBackoffDelayMilliseconds = 2000; + bool restoreSucceeded = false; + for (int attempt = 1; attempt <= maxAttempts; attempt++) { + var logPath = $"{logPathBase}-attempt{attempt}.binlog"; + var runner = new ProcessRunner (Configurables.Paths.DotNetPreviewTool, "restore", + packageDownloadProj, + "--configfile", Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "NuGet.config"), + $"-bl:{logPath}", + "--verbosity", "normal" + ) { + EchoStandardOutput = true, + EchoStandardError = true, + }; + if (runner.Run ()) { + restoreSucceeded = true; + break; + } + if (attempt < maxAttempts) { + Log.WarningLine ($"Failed to restore runtime packs (attempt {attempt}/{maxAttempts}), retrying..."); + var delayMilliseconds = initialBackoffDelayMilliseconds * (1 << (attempt - 1)); + await Task.Delay (delayMilliseconds); + } + } + if (!restoreSucceeded) { + Log.ErrorLine ($"Failed to restore runtime packs using '{packageDownloadProj}' after {maxAttempts} attempts."); return false; }