diff --git a/Documentation/guides/messages/README.md b/Documentation/guides/messages/README.md index bab9d5dc5d0..e137dd0b20d 100644 --- a/Documentation/guides/messages/README.md +++ b/Documentation/guides/messages/README.md @@ -100,6 +100,7 @@ package from all the users on device and try again. If that does not work you ca Fast Deployment is not currently supported on this device. Please file an issue with the exact error message using the 'Help->Send Feedback->Report a Problem' menu item in Visual Studio or 'Help->Report a Problem' in Visual Studio for Mac. ++ [XA0138](xa0138.md): @(AndroidAsset) build action does not support 'AssetPack' Metadata in Library Projects. ## XA1xxx: Project related diff --git a/Documentation/guides/messages/xa0138.md b/Documentation/guides/messages/xa0138.md new file mode 100644 index 00000000000..23249009439 --- /dev/null +++ b/Documentation/guides/messages/xa0138.md @@ -0,0 +1,13 @@ +title: Xamarin.Android error XA0138 +description: XA0138 error code +ms.date: 02/05/2024 +--- +# Xamarin.Android error XA0138 + +## Issue + +@(AndroidAsset) build action does not support 'AssetPack' or 'DeliveryType' Metadata in Library Projects. + +## Solution + +Remove the 'AssetPack' or 'DeliveryType' Metadata from your `AndroidAsset` build Items. \ No newline at end of file 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 c5605c9cc56..d35ba6307f5 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 @@ -74,6 +74,17 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. + + + <_AssetsWithAssetPackMetaData Include="@(AndroidAsset)" Condition=" '%(AndroidAsset.AssetPack)' != '' " /> + + + + diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets index 19d0c698d1f..0af519311ef 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets @@ -76,6 +76,7 @@ properties that determine build ordering. _LintChecks; _IncludeNativeSystemLibraries; _CheckGoogleSdkRequirements; + _BuildAssetPacks; @@ -91,6 +92,7 @@ properties that determine build ordering. _AddAndroidDefines; _CheckForContent; _CheckForObsoleteFrameworkAssemblies; + _CheckForAssetPackInLibraryProject; _RemoveLegacyDesigner; _ValidateAndroidPackageProperties; AddLibraryJarsToBind; diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx index a1a45e18ff3..75b410c61a4 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx @@ -329,6 +329,10 @@ If this file comes from a NuGet package, update to a newer version of the NuGet The capitalized word "Portable" that appears earlier in the message is plain text and should be translated, but the lowercase word "portable" later in the message is a literal value and should not be translated. {0} - The file name of a deprecated symbol file + + @(AndroidAsset) build action does not support 'AssetPack' or 'DeliveryType' Metadata in Library Projects. + + There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} {0} - The file name diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AssetPackTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AssetPackTests.cs index 21d9c782c9c..65ea011c174 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AssetPackTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AssetPackTests.cs @@ -10,6 +10,29 @@ namespace Xamarin.Android.Build.Tests [Parallelizable (ParallelScope.Children)] public class AssetPackTests : BaseTest { + [Test] + [Category ("SmokeTests")] + public void BuildLibraryWithAssetPack ([Values (true, false)] bool isRelease) + { + var path = Path.Combine ("temp", TestName); + var lib = new XamarinAndroidLibraryProject { + IsRelease = isRelease, + OtherBuildItems = { + new AndroidItem.AndroidAsset ("Assets\\asset1.txt") { + TextContent = () => "Asset1", + Encoding = Encoding.ASCII, + MetadataValues="AssetPack=assetpack1", + }, + } + }; + using (var builder = CreateDllBuilder (Path.Combine (path, lib.ProjectName))) { + builder.ThrowOnBuildFailure = false; + Assert.IsFalse (builder.Build (lib), $"{lib.ProjectName} should fail."); + StringAssertEx.Contains ("error XA0138: @(AndroidAsset) build action does not support 'AssetPack' or 'DeliveryType' Metadata in Library Projects.", builder.LastBuildOutput, + "Build Output did not contain error XA0138'."); + } + } + [Test] [Category ("SmokeTests")] public void BuildApplicationWithAssetPackOverrides ([Values (true, false)] bool isRelease)