From 19d007070e6434ded39cf05a05affc9f082496c1 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Tue, 18 Apr 2023 11:41:42 +0100 Subject: [PATCH 1/3] [Xamarin.Android.Build.Tasks] Allow override of `uncompressedGlob`. Users reported that when they added a custom `uncompressedGlob` entry to the `$(AndroidBundleConfigurationFile)`, it was ignored. This is because the `MergeArrayHandling` option we were using in the `BuildAppBundle` task was set to `MergeArrayHandling.Replace`. As a result we would just overwrite the user config with our own. We should be using the `MergeArrayHandling.Union` option instead. This with merge the arrays , but will remove duplicates. This should allow users to provide additional `uncompressedGlob` options. A unit test has been added to test this new behaviour. --- src/Xamarin.Android.Build.Tasks/Tasks/BuildAppBundle.cs | 2 +- tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/BuildAppBundle.cs b/src/Xamarin.Android.Build.Tasks/Tasks/BuildAppBundle.cs index 213e09272d2..016654829dc 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/BuildAppBundle.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/BuildAppBundle.cs @@ -102,7 +102,7 @@ public override bool RunTask () }); var mergeSettings = new JsonMergeSettings () { - MergeArrayHandling = MergeArrayHandling.Replace, + MergeArrayHandling = MergeArrayHandling.Union, MergeNullValueHandling = MergeNullValueHandling.Ignore }; json.Merge (jsonAddition, mergeSettings); diff --git a/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs b/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs index c6976df1e2e..78538e50734 100644 --- a/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs @@ -29,6 +29,11 @@ public class BundleToolTests : DeviceTest // Disable split by language const string BuildConfig = @"{ + ""compression"": { + ""uncompressedGlob"": [ + ""assets/*.data"" + ] + }, ""optimizations"": { ""splits_config"": { ""split_dimension"": [ @@ -77,6 +82,9 @@ public void OneTimeSetUp () app.OtherBuildItems.Add (new AndroidItem.AndroidAsset ("foo.wav") { BinaryContent = () => bytes, }); + app.OtherBuildItems.Add (new AndroidItem.AndroidAsset ("foo.data") { + BinaryContent = () => bytes, + }); app.OtherBuildItems.Add (new BuildItem ("None", "buildConfig.json") { TextContent = () => BuildConfig, }); @@ -324,6 +332,7 @@ public void ApkSet () var uncompressed = new List { ".bar", ".wav", + ".data", }; if (usesAssemblyBlobs) { From 598db238dc53ae796513b084b2999ed7764018e0 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 19 Apr 2023 10:14:41 +0100 Subject: [PATCH 2/3] Add Tests --- .../Tests/DebuggingTest.cs | 70 ++++++++++++++++++- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs index cffcf4e3279..1dddd2c7b26 100755 --- a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs @@ -136,21 +136,43 @@ public void ClassLibraryMainLauncherRuns ([Values (true, false)] bool preloadAss /* embedAssemblies */ true, /* fastDevType */ "Assemblies", /* activityStarts */ true, + /* packageFormat */ "apk", }, new object[] { /* embedAssemblies */ false, /* fastDevType */ "Assemblies", /* activityStarts */ true, + /* packageFormat */ "apk", }, new object[] { /* embedAssemblies */ true, /* fastDevType */ "Assemblies:Dexes", /* activityStarts */ true, + /* packageFormat */ "apk", }, new object[] { /* embedAssemblies */ false, /* fastDevType */ "Assemblies:Dexes", /* activityStarts */ false, + /* packageFormat */ "apk", + }, + new object[] { + /* embedAssemblies */ true, + /* fastDevType */ "Assemblies", + /* activityStarts */ true, + /* packageFormat */ "aab", + }, + new object[] { + /* embedAssemblies */ false, + /* fastDevType */ "Assemblies", + /* activityStarts */ true, + /* packageFormat */ "aab", + }, + new object[] { + /* embedAssemblies */ true, + /* fastDevType */ "Assemblies:Dexes", + /* activityStarts */ true, + /* packageFormat */ "aab", }, }; #pragma warning restore 414 @@ -158,7 +180,7 @@ public void ClassLibraryMainLauncherRuns ([Values (true, false)] bool preloadAss [Test, Category ("Debugger")] [TestCaseSource (nameof (DebuggerCustomAppTestCases))] [Retry(5)] - public void CustomApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, string fastDevType, bool activityStarts) + public void CustomApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, string fastDevType, bool activityStarts, string packageFormat) { AssertCommercialBuild (); SwitchUser (); @@ -175,6 +197,7 @@ public void CustomApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, st }; proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64"); proj.SetProperty ("EmbedAssembliesIntoApk", embedAssemblies.ToString ()); + proj.SetProperty ("AndroidPackageFormat", packageFormat); proj.SetDefaultTargetDevice (); proj.Sources.Add (new BuildItem.Source ("MyApplication.cs") { TextContent = () => proj.ProcessSourceTemplate (@"using System; @@ -281,42 +304,84 @@ public override void OnCreate () /* fastDevType */ "Assemblies", /* allowDeltaInstall */ false, /* user */ null, + /* packageFormat */ "apk", }, new object[] { /* embedAssemblies */ false, /* fastDevType */ "Assemblies", /* allowDeltaInstall */ false, /* user */ null, + /* packageFormat */ "apk", }, new object[] { /* embedAssemblies */ false, /* fastDevType */ "Assemblies", /* allowDeltaInstall */ true, /* user */ null, + /* packageFormat */ "apk", }, new object[] { /* embedAssemblies */ false, /* fastDevType */ "Assemblies:Dexes", /* allowDeltaInstall */ false, /* user */ null, + /* packageFormat */ "apk", }, new object[] { /* embedAssemblies */ false, /* fastDevType */ "Assemblies:Dexes", /* allowDeltaInstall */ true, /* user */ null, + /* packageFormat */ "apk", + }, + new object[] { + /* embedAssemblies */ true, + /* fastDevType */ "Assemblies", + /* allowDeltaInstall */ false, + /* user */ DeviceTest.GuestUserName, + /* packageFormat */ "apk", + }, + new object[] { + /* embedAssemblies */ false, + /* fastDevType */ "Assemblies", + /* allowDeltaInstall */ false, + /* user */ DeviceTest.GuestUserName, + /* packageFormat */ "apk", + }, + new object[] { + /* embedAssemblies */ true, + /* fastDevType */ "Assemblies", + /* allowDeltaInstall */ false, + /* user */ null, + /* packageFormat */ "aab", + }, + new object[] { + /* embedAssemblies */ false, + /* fastDevType */ "Assemblies", + /* allowDeltaInstall */ false, + /* user */ null, + /* packageFormat */ "aab", + }, + new object[] { + /* embedAssemblies */ false, + /* fastDevType */ "Assemblies", + /* allowDeltaInstall */ true, + /* user */ null, + /* packageFormat */ "aab", }, new object[] { /* embedAssemblies */ true, /* fastDevType */ "Assemblies", /* allowDeltaInstall */ false, /* user */ DeviceTest.GuestUserName, + /* packageFormat */ "aab", }, new object[] { /* embedAssemblies */ false, /* fastDevType */ "Assemblies", /* allowDeltaInstall */ false, /* user */ DeviceTest.GuestUserName, + /* packageFormat */ "aab", }, }; #pragma warning restore 414 @@ -324,7 +389,7 @@ public override void OnCreate () [Test, Category ("Debugger")] [TestCaseSource (nameof(DebuggerTestCases))] [Retry (5)] - public void ApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, string fastDevType, bool allowDeltaInstall, string username) + public void ApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, string fastDevType, bool allowDeltaInstall, string username, string packageFormat) { AssertCommercialBuild (); SwitchUser (); @@ -367,6 +432,7 @@ public Foo () EmbedAssembliesIntoApk = embedAssemblies, AndroidFastDeploymentType = fastDevType }; + app.SetProperty ("AndroidPackageFormat", packageFormat); app.MainPage = app.MainPage.Replace ("InitializeComponent ();", "InitializeComponent (); new Foo ();"); app.AddReference (lib); app.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64"); From 32ea4318d842a3861b8847295bac35bfdcbcbdf1 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Thu, 15 Jun 2023 14:22:35 +0100 Subject: [PATCH 3/3] Remove tests the just will not work --- .../Tests/DebuggingTest.cs | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs index 1dddd2c7b26..712bd184795 100755 --- a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs @@ -162,12 +162,6 @@ public void ClassLibraryMainLauncherRuns ([Values (true, false)] bool preloadAss /* activityStarts */ true, /* packageFormat */ "aab", }, - new object[] { - /* embedAssemblies */ false, - /* fastDevType */ "Assemblies", - /* activityStarts */ true, - /* packageFormat */ "aab", - }, new object[] { /* embedAssemblies */ true, /* fastDevType */ "Assemblies:Dexes", @@ -355,20 +349,6 @@ public override void OnCreate () /* user */ null, /* packageFormat */ "aab", }, - new object[] { - /* embedAssemblies */ false, - /* fastDevType */ "Assemblies", - /* allowDeltaInstall */ false, - /* user */ null, - /* packageFormat */ "aab", - }, - new object[] { - /* embedAssemblies */ false, - /* fastDevType */ "Assemblies", - /* allowDeltaInstall */ true, - /* user */ null, - /* packageFormat */ "aab", - }, new object[] { /* embedAssemblies */ true, /* fastDevType */ "Assemblies", @@ -376,13 +356,6 @@ public override void OnCreate () /* user */ DeviceTest.GuestUserName, /* packageFormat */ "aab", }, - new object[] { - /* embedAssemblies */ false, - /* fastDevType */ "Assemblies", - /* allowDeltaInstall */ false, - /* user */ DeviceTest.GuestUserName, - /* packageFormat */ "aab", - }, }; #pragma warning restore 414