Skip to content

Commit

Permalink
Add Error for Library Projects
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 committed Feb 5, 2024
1 parent d76375b commit f900a76
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions Documentation/guides/messages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions Documentation/guides/messages/xa0138.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
</ItemGroup>
</Target>

<Target Name="_CheckForAssetPackInLibraryProject" Condition=" '$(AndroidApplication)' != 'true' ">
<ItemGroup>
<_AssetsWithAssetPackMetaData Include="@(AndroidAsset)" Condition=" '%(AndroidAsset.AssetPack)' != '' " />
</ItemGroup>
<AndroidError
Code="XA0138"
ResourceName="XA0138"
Condition=" '@(_AssetsWithAssetPackMetaData->Count())' != '0' "
/>
</Target>

<Target Name="_CalculateAssetPacks"
Condition=" ('$(AndroidPackageFormat)' == 'aab' And '$(AndroidApplication)' == 'true') "
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ properties that determine build ordering.
_LintChecks;
_IncludeNativeSystemLibraries;
_CheckGoogleSdkRequirements;
_BuildAssetPacks;
</_PrepareBuildApkDependsOnTargets>
</PropertyGroup>

Expand All @@ -91,6 +92,7 @@ properties that determine build ordering.
_AddAndroidDefines;
_CheckForContent;
_CheckForObsoleteFrameworkAssemblies;
_CheckForAssetPackInLibraryProject;
_RemoveLegacyDesigner;
_ValidateAndroidPackageProperties;
AddLibraryJarsToBind;
Expand Down
4 changes: 4 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -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</comment>
</data>
<data name="XA0138" xml:space="preserve">
<value>@(AndroidAsset) build action does not support 'AssetPack' or 'DeliveryType' Metadata in Library Projects.</value>
<comment></comment>
</data>
<data name="XA1000" xml:space="preserve">
<value>There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1}</value>
<comment>{0} - The file name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f900a76

Please sign in to comment.