From 7c24387272a9d928d3fbdd297d84e39d16a07d18 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Wed, 5 Feb 2025 22:11:02 -0500 Subject: [PATCH 1/5] Try dotnet/java-interop#1304 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Does It Build™? --- .gitmodules | 2 +- external/Java.Interop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index ea5f83ceb43..1f8fa1f3bb5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,7 +13,7 @@ [submodule "external/Java.Interop"] path = external/Java.Interop url = https://github.com/dotnet/java-interop - branch = main + branch = dev/jonp/jonp-dotnet-requires-plus-not-slash-take2 [submodule "external/libunwind"] path = external/libunwind url = https://github.com/libunwind/libunwind.git diff --git a/external/Java.Interop b/external/Java.Interop index dd3c1d0514a..a32e0e1df1a 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit dd3c1d0514addfe379f050627b3e97493e985da6 +Subproject commit a32e0e1df1a84d9042bb5a754507987f7b93eae9 From f501f99378036bdc09009adca8cef5631f9df072 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 6 Feb 2025 13:06:43 -0500 Subject: [PATCH 2/5] =?UTF-8?q?Does=20It=20(Still)=20Build=E2=84=A2=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- external/Java.Interop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/Java.Interop b/external/Java.Interop index a32e0e1df1a..d0f28fdef91 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit a32e0e1df1a84d9042bb5a754507987f7b93eae9 +Subproject commit d0f28fdef91202160b41c3e6d99c7d6572d78402 From a722ee90647a197d9d945f1a26a9d2efece3cfe3 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 6 Feb 2025 14:02:31 -0500 Subject: [PATCH 3/5] Better log API changes to Mono.Android.dll If (when?) an API change is made to Mono.Android.dll, `src/Mono.Android/ApiCompatLinesToAdd.txt` will be created containing the lines that need to be added to e.g. `tests/api-compatibility/acceptable-breakages-vReference-*.txt` so that the changes are ignored. These lines can then be easily copied into `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. --- .../CheckApiCompatibility.cs | 19 +++++++++++++++++++ src/Mono.Android/Mono.Android.targets | 1 + 2 files changed, 20 insertions(+) diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs index cbbf6aa355b..f7d15a7ca07 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs @@ -67,6 +67,9 @@ public sealed class CheckApiCompatibility : Task // In case API diffs vary between e.g. Classic MonoAndroid & .NET 6+ public string TargetFramework { get; set; } + // What's missing from acceptableIssuesFile? + public string LinesToAdd { get; set; } + // This Build tasks validates that changes are not breaking Api public override bool Execute () { @@ -260,6 +263,7 @@ void dataReceived (object sender, DataReceivedEventArgs args) } LogError ($"CheckApiCompatibility found nonacceptable Api breakages for ApiLevel: {ApiLevel}.{Environment.NewLine}{string.Join (Environment.NewLine, lines)}"); + ReportMissingLines (acceptableIssuesFile.FullName, lines); var missingItems = CodeGenDiff.GenerateMissingItems (CodeGenPath, contractAssembly.FullName, implementationAssembly.FullName); if (missingItems.Any ()) { @@ -285,6 +289,21 @@ void dataReceived (object sender, DataReceivedEventArgs args) } } + void ReportMissingLines (string acceptableIssuesFile, List lines) + { + if (string.IsNullOrWhiteSpace (LinesToAdd)) { + return; + } + var known = new HashSet (File.ReadAllLines (acceptableIssuesFile), StringComparer.Ordinal); + using var writer = File.CreateText (LinesToAdd); + foreach (var line in lines) { + if (known.Contains (line)) { + continue; + } + writer.WriteLine (line); + } + } + void LogError (string errorMessage) { if (!string.IsNullOrWhiteSpace (compatApiCommand)) { diff --git a/src/Mono.Android/Mono.Android.targets b/src/Mono.Android/Mono.Android.targets index 2f3093bd6c2..7c1daaa38bf 100644 --- a/src/Mono.Android/Mono.Android.targets +++ b/src/Mono.Android/Mono.Android.targets @@ -225,6 +225,7 @@ TargetImplementationPath="$(OutputPath)" ApiCompatibilityPath="$(ApiCompatibilityDir)" TargetFramework="$(TargetFramework)" + LinesToAdd="$(MSBuildThisFileDirectory)ApiCompatLinesToAdd.txt" /> Date: Thu, 6 Feb 2025 15:47:46 -0500 Subject: [PATCH 4/5] Bump to dotnet/java-interop/main@6bc87e8b --- .gitmodules | 2 +- external/Java.Interop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 1f8fa1f3bb5..ea5f83ceb43 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,7 +13,7 @@ [submodule "external/Java.Interop"] path = external/Java.Interop url = https://github.com/dotnet/java-interop - branch = dev/jonp/jonp-dotnet-requires-plus-not-slash-take2 + branch = main [submodule "external/libunwind"] path = external/libunwind url = https://github.com/libunwind/libunwind.git diff --git a/external/Java.Interop b/external/Java.Interop index d0f28fdef91..6bc87e8b55b 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit d0f28fdef91202160b41c3e6d99c7d6572d78402 +Subproject commit 6bc87e8b55bc00ae1423a5ae92cf5db573fc76ed From 518370c7797a11c43f22e52dc2346cb226d21dea Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 6 Feb 2025 20:11:28 -0500 Subject: [PATCH 5/5] "Better" try to install the .NET preview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Context: https://github.com/dotnet/android/pull/9761 Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=10967971&view=logs&j=54890acb-4627-5ef0-3b6b-f3b3aa2a1f64&t=c15bce3e-6894-5f6e-fad7-4116b0f4ba81 The **macOS > Build** stage is failing -- after 3 retries! -- because it can't install .NET: 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] doesn't exist on . 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` report: % 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, ! @jonpryor believes that the cached `dotnet-install.sh` script on this particular build machine is too old. 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 --- .../xaprepare/Steps/Step_InstallDotNetPreview.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs index b1bdc516e61..36ee3c1f958 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs @@ -21,7 +21,8 @@ protected override async Task Execute (Context context) var dotnetPath = Configurables.Paths.DotNetPreviewPath; dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar }); - if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion)) { + if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: true) && + !await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: false)) { Log.ErrorLine ($"Installation of dotnet SDK '{BuildToolVersion}' failed."); return false; } @@ -77,17 +78,18 @@ protected override async Task Execute (Context context) return true; } - async Task DownloadDotNetInstallScript (Context context, string dotnetScriptPath, Uri dotnetScriptUrl) + async Task DownloadDotNetInstallScript (Context context, string dotnetScriptPath, Uri dotnetScriptUrl, bool useCachedInstallScript) { string tempDotnetScriptPath = dotnetScriptPath + "-tmp"; Utilities.DeleteFile (tempDotnetScriptPath); Log.StatusLine ("Downloading dotnet-install script..."); - if (File.Exists (dotnetScriptPath)) { + if (useCachedInstallScript && File.Exists (dotnetScriptPath)) { Log.WarningLine ($"Using cached installation script found in '{dotnetScriptPath}'"); return true; } + Utilities.DeleteFile (dotnetScriptPath); Log.StatusLine ($" {context.Characters.Link} {dotnetScriptUrl}", ConsoleColor.White); await Utilities.Download (dotnetScriptUrl, tempDotnetScriptPath, DownloadStatus.Empty); @@ -173,7 +175,7 @@ string[] GetInstallationScriptArgs (string version, string dotnetPath, string do return args.ToArray (); } - async Task InstallDotNetAsync (Context context, string dotnetPath, string version, bool runtimeOnly = false) + async Task InstallDotNetAsync (Context context, string dotnetPath, string version, bool useCachedInstallScript, bool runtimeOnly = false) { string cacheDir = context.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory); @@ -183,7 +185,7 @@ async Task InstallDotNetAsync (Context context, string dotnetPath, string Uri dotnetScriptUrl = Configurables.Urls.DotNetInstallScript; string scriptFileName = Path.GetFileName (dotnetScriptUrl.LocalPath); string cachedDotnetScriptPath = Path.Combine (cacheDir, scriptFileName); - if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl)) { + if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl, useCachedInstallScript)) { return false; }