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/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; } diff --git a/external/Java.Interop b/external/Java.Interop index dd3c1d0514a..6bc87e8b55b 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit dd3c1d0514addfe379f050627b3e97493e985da6 +Subproject commit 6bc87e8b55bc00ae1423a5ae92cf5db573fc76ed 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" />