Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] Fix up AndroidStoreUncompressedFileExte…
Browse files Browse the repository at this point in the history
…nsions. (dotnet#3968)

Fixes dotnet#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.

* Added Unit Test
* Fixed Native Library Compression Method
  • Loading branch information
dellis1972 authored and jonathanpeppers committed Dec 9, 2019
1 parent 68324d0 commit 6e40a8f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ HashSet<string> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6e40a8f

Please sign in to comment.