From 207ed6274252a515a0bff62e44506bf43ae21194 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 17 Jan 2024 09:35:04 +0000 Subject: [PATCH] Add suppport for multiple Asset directories --- .../Xamarin/Android/Xamarin.Android.Assets.targets | 2 +- .../Tasks/Aapt2LinkAssetPack.cs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Assets.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Assets.targets index eb96ae3a013..2002a9563f8 100644 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Assets.targets +++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Assets.targets @@ -111,7 +111,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. DaemonMaxInstanceCount="$(Aapt2DaemonMaxInstanceCount)" DaemonKeepInDomain="$(_Aapt2DaemonKeepInDomain)" OutputArchive="%(_AssetPacks.AssetPackOutput)" - AssetDirectory="$(MonoAndroidAssetPacksDirIntermediate)\%(_AssetPacks.AssetPack)\assets" + AssetDirectories="$(MonoAndroidAssetPacksDirIntermediate)\%(_AssetPacks.AssetPack)\assets" Manifest="%(_AssetPacks.ManifestFile)" PackageName="$(_AndroidPackage).%(_AssetPacks.AssetPack)" ToolPath="$(Aapt2ToolPath)" diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs index 1f17af5374b..1370a7a6631 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs @@ -21,7 +21,7 @@ public class Aapt2LinkAssetPack : Aapt2 { public ITaskItem Manifest { get; set; } [Required] - public ITaskItem AssetDirectory { get; set; } + public ITaskItem[] AssetDirectories { get; set; } [Required] public string PackageName { get; set; } @@ -38,7 +38,7 @@ protected override int GetRequiredDaemonInstances () public async override System.Threading.Tasks.Task RunTaskAsync () { - RunAapt (GenerateCommandLineCommands (Manifest, AssetDirectory, OutputArchive), OutputArchive.ItemSpec); + RunAapt (GenerateCommandLineCommands (Manifest, OutputArchive), OutputArchive.ItemSpec); ProcessOutput (); if (OutputFormat == "proto" && File.Exists (OutputArchive.ItemSpec)) { // move the manifest to the right place. @@ -49,7 +49,7 @@ public async override System.Threading.Tasks.Task RunTaskAsync () } } - protected string[] GenerateCommandLineCommands (ITaskItem manifest, ITaskItem assetDirectory, ITaskItem output) + protected string[] GenerateCommandLineCommands (ITaskItem manifest, ITaskItem output) { //link --manifest AndroidManifest.xml --proto-format --custom-package $(Package) -A $(AssetsDirectory) -o $(_TempOutputFile) List cmd = new List (); @@ -63,8 +63,10 @@ protected string[] GenerateCommandLineCommands (ITaskItem manifest, ITaskItem as } cmd.Add ("--custom-package"); cmd.Add (PackageName); - cmd.Add ("-A"); - cmd.Add (GetFullPath (assetDirectory.ItemSpec)); + foreach (var assetDirectory in AssetDirectories) { + cmd.Add ("-A"); + cmd.Add (GetFullPath (assetDirectory.ItemSpec)); + } cmd.Add ($"-o"); cmd.Add (GetFullPath (output.ItemSpec)); return cmd.ToArray ();