Skip to content

Commit 6862b52

Browse files
authored
[xaprepare] Fix dotnet-install script size check (#8311)
CI builds have been failing frequently and quietly: Downloading dotnet-install... Error: Installation of dotnet SDK 8.0.100-rc.2.23422.31 failed. Step Xamarin.Android.Prepare.Step_InstallDotNetPreview failed System.InvalidOperationException: Step Xamarin.Android.Prepare.Step_InstallDotNetPreview failed We were returning early when attempts to calculate the size of the `dotnet-install` script failed, and a cached install script file was not already on disk. This has been fixed by ensuring that we still attempt to download the script if the size calculation fails. The size check failure has also been fixed by using a get request, and logging around this prepare step has been improved.
1 parent a48a9c5 commit 6862b52

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

build-tools/xaprepare/xaprepare/Application/Utilities.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,7 @@ public static HttpClient CreateHttpClient ()
488488
try {
489489
using (HttpClient httpClient = CreateHttpClient ()) {
490490
httpClient.Timeout = WebRequestTimeout;
491-
var req = new HttpRequestMessage (HttpMethod.Head, url);
492-
req.Headers.ConnectionClose = true;
493-
494-
HttpResponseMessage resp = await httpClient.SendAsync (req, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait (true);
491+
HttpResponseMessage resp = await httpClient.GetAsync (url, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait (true);
495492
if (!resp.IsSuccessStatusCode || !resp.Content.Headers.ContentLength.HasValue)
496493
return (false, 0, resp.StatusCode);
497494

build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected override async Task<bool> Execute (Context context)
2222
dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar });
2323

2424
if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion)) {
25-
Log.ErrorLine ($"Installation of dotnet SDK {BuildToolVersion} failed.");
25+
Log.ErrorLine ($"Installation of dotnet SDK '{BuildToolVersion}' failed.");
2626
return false;
2727
}
2828

@@ -47,7 +47,7 @@ protected override async Task<bool> Execute (Context context)
4747
ProcessRunner.QuoteArgument ($"-bl:{logPath}"),
4848
};
4949
if (!Utilities.RunCommand (Configurables.Paths.DotNetPreviewTool, restoreArgs)) {
50-
Log.ErrorLine ($"dotnet restore {packageDownloadProj} failed.");
50+
Log.ErrorLine ($"Failed to restore runtime packs using '{packageDownloadProj}'.");
5151
return false;
5252
}
5353

@@ -74,18 +74,19 @@ async Task<bool> DownloadDotNetInstallScript (Context context, string dotnetScri
7474
string tempDotnetScriptPath = dotnetScriptPath + "-tmp";
7575
Utilities.DeleteFile (tempDotnetScriptPath);
7676

77-
Log.StatusLine ("Downloading dotnet-install...");
77+
Log.StatusLine ("Downloading dotnet-install script...");
7878

7979
(bool success, ulong size, HttpStatusCode status) = await Utilities.GetDownloadSizeWithStatus (dotnetScriptUrl);
8080
if (!success) {
8181
string message;
8282
if (status == HttpStatusCode.NotFound) {
83-
message = "dotnet-install URL not found";
83+
message = $"dotnet-install URL '{dotnetScriptUrl}' not found.";
8484
} else {
85-
message = $"Failed to obtain dotnet-install size. HTTP status code: {status} ({(int)status})";
85+
message = $"Failed to obtain dotnet-install script size from URL '{dotnetScriptUrl}'. HTTP status code: {status} ({(int)status})";
8686
}
8787

88-
return ReportAndCheckCached (message, quietOnError: true);
88+
if (ReportAndCheckCached (message, quietOnError: true))
89+
return true;
8990
}
9091

9192
DownloadStatus downloadStatus = Utilities.SetupDownloadStatus (context, size, context.InteractiveSession);
@@ -192,6 +193,7 @@ async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string
192193
string scriptFileName = Path.GetFileName (dotnetScriptUrl.LocalPath);
193194
string cachedDotnetScriptPath = Path.Combine (cacheDir, scriptFileName);
194195
if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl)) {
196+
Log.ErrorLine ($"Failed to download dotnet-install script.");
195197
return false;
196198
}
197199

0 commit comments

Comments
 (0)