Skip to content

Commit a941e34

Browse files
authored
Context: #9747 Changes: dotnet/java-interop@dd3c1d0...6bc87e8 * dotnet/java-interop@6bc87e8b: [jcw-gen] Use `+` for nested types, not `/` (dotnet/java-interop#1304) dotnet/java-interop@6bc87e8b is needed to unblock parts of #9747. Additionally, two "quality of life" changes: Firstly, update the `src/Mono.Android` build so that if there are API breaks reported, the breakage is collated into `src/Mono.Android/ApiCompatLinesToAdd.txt` in a format that can be directly copied into `tests/api-compatibility/acceptable-breakages-vReference-*.txt` if deemed useful. Previously, *all* changes were printed to the build log, which was annoying to deal with because (1) there may be duplicates, and (2) the lines would contain `TaskId`/etc. "noise" that would need to be removed in order to be used. Secondly, update `build-tools/xaprepare` to improve reliability when running `Step_InstallDotNetPreview`. `Step_InstallDotNetPreview` will cache e.g. `dotnet-install.sh` into `$HOME/android-archives`, but there was no logic to verify that it was still *valid*. We've been seeing some recurring build failures in **macOS > Build** such as: Downloading dotnet-install script... Warning: Using cached installation script found in '/Users/builder/android-archives/dotnet-install.sh' Discovering download URLs for dotnet SDK '10.0.100-preview.2.25102.3'... Downloading dotnet archive... dotnet archive URL https://dotnetcli.azureedge.net/dotnet/Sdk/10.0.100-preview.2.25102.3/dotnet-sdk-10.0.100-preview.2.25102.3-osx-arm64.tar.gz not found Downloading dotnet archive... dotnet archive URL https://dotnetcli.azureedge.net/dotnet/Sdk/10.0.100-preview.2.25102.3/dotnet-dev-osx-arm64.10.0.100-preview.2.25102.3.tar.gz not found Downloading dotnet archive... Warning: Failed to obtain dotnet archive size. HTTP status code: InternalServerError (500) Downloading dotnet archive... Warning: Failed to obtain dotnet archive size. HTTP status code: InternalServerError (500) Error: Installation of dotnet SDK '10.0.100-preview.2.25102.3' failed. Step Xamarin.Android.Prepare.Step_InstallDotNetPreview failed System.InvalidOperationException: Step Xamarin.Android.Prepare.Step_InstallDotNetPreview failed at Xamarin.Android.Prepare.Scenario.Run(Context context, Log log) in /Users/builder/azdo/_work/8/s/xamarin-android/build-tools/xaprepare/xaprepare/Application/Scenario.cs:line 50 at Xamarin.Android.Prepare.Context.Execute() in /Users/builder/azdo/_work/8/s/xamarin-android/build-tools/xaprepare/xaprepare/Application/Context.cs:line 488 at Xamarin.Android.Prepare.App.Run(String[] args) in /Users/builder/azdo/_work/8/s/xamarin-android/build-tools/xaprepare/xaprepare/Main.cs:line 155 Indeed, [`dotnet-sdk-10.0.100-preview.2.25102.3-osx-arm64.tar.gz`][0] no longer exists on <https://dotnetcli.azureedge.net>. The problem, though, is that .NET changed the CDN that is used in the past month, and that's not the correct URL. A newer `dotnet-install.sh` reports: % bash "…/dotnet-install.sh" "--version" "10.0.100-preview.2.25102.3" "--install-dir" "/Volumes/Xamarin-Work/src/dotnet/android/bin/Release/dotnet" "--verbose" "--dry-run … dotnet-install: Link 0: primary, 10.0.100-preview.2.25102.3, https://builds.dotnet.microsoft.com/dotnet/Sdk/10.0.100-preview.2.25102.3/dotnet-sdk-10.0.100-preview.2.25102.3-osx-x64.tar.gz dotnet-install: Link 1: legacy, 10.0.100-preview.2.25102.3, https://builds.dotnet.microsoft.com/dotnet/Sdk/10.0.100-preview.2.25102.3/dotnet-dev-osx-x64.10.0.100-preview.2.25102.3.tar.gz dotnet-install: Link 2: primary, 10.0.100-preview.2.25102.3, https://ci.dot.net/public/Sdk/10.0.100-preview.2.25102.3/dotnet-sdk-10.0.100-preview.2.25102.3-osx-x64.tar.gz dotnet-install: Link 3: legacy, 10.0.100-preview.2.25102.3, https://ci.dot.net/public/Sdk/10.0.100-preview.2.25102.3/dotnet-dev-osx-x64.10.0.100-preview.2.25102.3.tar.gz Note the different domain, <https://builds.dotnet.microsoft.com>! Update `Step_InstallDotNetPreview` to try to install .NET potentially *twice*: the first time using the cached `dotnet-install.sh`, and *if that fails*, it tries again after downloading a *new* `dotnet-install.sh`. Hopefully this will fix the build failure on this machine! [0]: https://dotnetcli.azureedge.net/dotnet/Sdk/10.0.100-preview.2.25102.3/dotnet-sdk-10.0.100-preview.2.25102.3-osx-arm64.tar.gz
1 parent b7e21ad commit a941e34

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs

+19
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public sealed class CheckApiCompatibility : Task
6767
// In case API diffs vary between e.g. Classic MonoAndroid & .NET 6+
6868
public string TargetFramework { get; set; }
6969

70+
// What's missing from acceptableIssuesFile?
71+
public string LinesToAdd { get; set; }
72+
7073
// This Build tasks validates that changes are not breaking Api
7174
public override bool Execute ()
7275
{
@@ -260,6 +263,7 @@ void dataReceived (object sender, DataReceivedEventArgs args)
260263
}
261264

262265
LogError ($"CheckApiCompatibility found nonacceptable Api breakages for ApiLevel: {ApiLevel}.{Environment.NewLine}{string.Join (Environment.NewLine, lines)}");
266+
ReportMissingLines (acceptableIssuesFile.FullName, lines);
263267

264268
var missingItems = CodeGenDiff.GenerateMissingItems (CodeGenPath, contractAssembly.FullName, implementationAssembly.FullName);
265269
if (missingItems.Any ()) {
@@ -285,6 +289,21 @@ void dataReceived (object sender, DataReceivedEventArgs args)
285289
}
286290
}
287291

292+
void ReportMissingLines (string acceptableIssuesFile, List<string> lines)
293+
{
294+
if (string.IsNullOrWhiteSpace (LinesToAdd)) {
295+
return;
296+
}
297+
var known = new HashSet<string> (File.ReadAllLines (acceptableIssuesFile), StringComparer.Ordinal);
298+
using var writer = File.CreateText (LinesToAdd);
299+
foreach (var line in lines) {
300+
if (known.Contains (line)) {
301+
continue;
302+
}
303+
writer.WriteLine (line);
304+
}
305+
}
306+
288307
void LogError (string errorMessage)
289308
{
290309
if (!string.IsNullOrWhiteSpace (compatApiCommand)) {

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ protected override async Task<bool> Execute (Context context)
2121
var dotnetPath = Configurables.Paths.DotNetPreviewPath;
2222
dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar });
2323

24-
if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion)) {
24+
if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: true) &&
25+
!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: false)) {
2526
Log.ErrorLine ($"Installation of dotnet SDK '{BuildToolVersion}' failed.");
2627
return false;
2728
}
@@ -77,17 +78,18 @@ protected override async Task<bool> Execute (Context context)
7778
return true;
7879
}
7980

80-
async Task<bool> DownloadDotNetInstallScript (Context context, string dotnetScriptPath, Uri dotnetScriptUrl)
81+
async Task<bool> DownloadDotNetInstallScript (Context context, string dotnetScriptPath, Uri dotnetScriptUrl, bool useCachedInstallScript)
8182
{
8283
string tempDotnetScriptPath = dotnetScriptPath + "-tmp";
8384
Utilities.DeleteFile (tempDotnetScriptPath);
8485

8586
Log.StatusLine ("Downloading dotnet-install script...");
8687

87-
if (File.Exists (dotnetScriptPath)) {
88+
if (useCachedInstallScript && File.Exists (dotnetScriptPath)) {
8889
Log.WarningLine ($"Using cached installation script found in '{dotnetScriptPath}'");
8990
return true;
9091
}
92+
Utilities.DeleteFile (dotnetScriptPath);
9193

9294
Log.StatusLine ($" {context.Characters.Link} {dotnetScriptUrl}", ConsoleColor.White);
9395
await Utilities.Download (dotnetScriptUrl, tempDotnetScriptPath, DownloadStatus.Empty);
@@ -173,7 +175,7 @@ string[] GetInstallationScriptArgs (string version, string dotnetPath, string do
173175
return args.ToArray ();
174176
}
175177

176-
async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string version, bool runtimeOnly = false)
178+
async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string version, bool useCachedInstallScript, bool runtimeOnly = false)
177179
{
178180
string cacheDir = context.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory);
179181

@@ -183,7 +185,7 @@ async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string
183185
Uri dotnetScriptUrl = Configurables.Urls.DotNetInstallScript;
184186
string scriptFileName = Path.GetFileName (dotnetScriptUrl.LocalPath);
185187
string cachedDotnetScriptPath = Path.Combine (cacheDir, scriptFileName);
186-
if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl)) {
188+
if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl, useCachedInstallScript)) {
187189
return false;
188190
}
189191

src/Mono.Android/Mono.Android.targets

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@
225225
TargetImplementationPath="$(OutputPath)"
226226
ApiCompatibilityPath="$(ApiCompatibilityDir)"
227227
TargetFramework="$(TargetFramework)"
228+
LinesToAdd="$(MSBuildThisFileDirectory)ApiCompatLinesToAdd.txt"
228229
/>
229230
<Touch
230231
Files="$(IntermediateOutputPath)CheckApiCompatibility.stamp"

0 commit comments

Comments
 (0)