From e57cfe71c8ba15cdad76a8c9a1fdeae717eb0d81 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 27 Nov 2019 13:19:31 +0000 Subject: [PATCH 1/3] [Xamarin.Android.Build.Tasks] Fix up AndroidStoreUncompressedFileExtensions. Fixes #3962 Commit d20a991 fixed up an issue where `aapt2` was always compressing items even if they were defined in `AndroidStoreUncompressedFileExtensions`. However users are not always including a period in the values they place in that ItemGroup. In the Linked issue the user was using `tflite` rather than `.tflite` which `aapt2` is expecrting. So lets check to see if we have a `.` prefix and if not add one. --- src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs | 2 +- src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs index 0fe92a5c14e..b62bc2833d2 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs @@ -332,7 +332,7 @@ protected string GenerateCommandLineCommands (string ManifestFile, string curren } if (!string.IsNullOrWhiteSpace (UncompressedFileExtensions)) foreach (var ext in UncompressedFileExtensions.Split (new char[] { ';', ','}, StringSplitOptions.RemoveEmptyEntries)) - cmd.AppendSwitchIfNotNull ("-0 ", ext); + cmd.AppendSwitchIfNotNull ("-0 ", ext.StartsWith (".", StringComparison.OrdinalIgnoreCase) ? ext : $".{ext}"); if (!string.IsNullOrEmpty (ExtraPackages)) cmd.AppendSwitchIfNotNull ("--extra-packages ", ExtraPackages); diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs index 54128d2351a..0254c6e9ee5 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs @@ -160,7 +160,7 @@ string GenerateCommandLineCommands (string ManifestFile, string currentAbi, stri if (!string.IsNullOrWhiteSpace (UncompressedFileExtensions)) foreach (var ext in UncompressedFileExtensions.Split (new char [] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries)) - cmd.AppendSwitchIfNotNull ("-0 ", ext); + cmd.AppendSwitchIfNotNull ("-0 ", ext.StartsWith (".", StringComparison.OrdinalIgnoreCase) ? ext : $".{ext}"); if (!string.IsNullOrEmpty (ExtraPackages)) cmd.AppendSwitchIfNotNull ("--extra-packages ", ExtraPackages); From 84fe505f7fc0f357bae9d93e14de213cf9a645f4 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Thu, 28 Nov 2019 12:25:29 +0000 Subject: [PATCH 2/3] Added Unit Test --- .../Tests/Xamarin.Android.Build.Tests/PackagingTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs index 21e60cf8a0b..13a4f9f7c2f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs @@ -180,7 +180,7 @@ public void CheckIncludedNativeLibraries ([Values (true, false)] bool compressNa proj.PackageReferences.Add(KnownPackages.SQLitePCLRaw_Core); proj.SetProperty ("AndroidUseAapt2", useAapt2.ToString ()); proj.SetProperty(proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, "x86"); - proj.SetProperty (proj.ReleaseProperties, "AndroidStoreUncompressedFileExtensions", compressNativeLibraries ? "" : ".so"); + proj.SetProperty (proj.ReleaseProperties, "AndroidStoreUncompressedFileExtensions", compressNativeLibraries ? "" : "so"); using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic; b.ThrowOnBuildFailure = false; From a8a931572f994921e9e0154c64f4ae3e3bfec105 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Thu, 5 Dec 2019 11:49:23 +0000 Subject: [PATCH 3/3] Fix Native Library Compression Method --- src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs b/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs index d9b5fcee43e..a1eb4f5454c 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs @@ -372,7 +372,7 @@ HashSet ParseProfilers (string value) CompressionMethod GetCompressionMethod (string fileName) { - if (uncompressedFileExtensions.Any (x => string.Compare (x, Path.GetExtension (fileName), StringComparison.OrdinalIgnoreCase) == 0)) + if (uncompressedFileExtensions.Any (x => string.Compare (x.StartsWith (".", StringComparison.OrdinalIgnoreCase) ? x : $".{x}", Path.GetExtension (fileName), StringComparison.OrdinalIgnoreCase) == 0)) return UncompressedMethod; return CompressionMethod.Default; }