diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs index fc00a08315f..ecf3a67fdf3 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs @@ -12,6 +12,51 @@ namespace Xamarin.Android.Build.Tests [Parallelizable (ParallelScope.Children)] public class BuildAssetsTest : BaseTest { + [Test] + public void CheckPostCompileAssetsIncludedInAPK () + { + var path = Path.Combine ("temp", TestName); + var proj = new XamarinAndroidApplicationProject () { + ProjectName = "App1", + IsRelease = true, + OtherBuildItems = { + new AndroidItem.AndroidAsset ("Assets\\asset3.txt") { + TextContent = () => "PlaceHolder", + Encoding = Encoding.ASCII, + }, + new AndroidItem.AndroidAsset ("Assets\\subfolder\\asset4.txt") { + TextContent = () => "Asset4", + Encoding = Encoding.ASCII, + }, + }, + Imports = { + new Import (() => "My.Test.target") { + TextContent = () => @" + + + +" + }, + }, + + }; + using (var b = CreateApkBuilder (Path.Combine (path, proj.ProjectName))) { + Assert.IsTrue (b.Build (proj), "{0} should have built successfully.", proj.ProjectName); + using (var apk = ZipHelper.OpenZip (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "bin", "packaged_resources"))) { + var item = "assets/asset3.txt"; + var data = ZipHelper.ReadFileFromZip (apk, item); + Assert.IsNotNull (data, "{0} should be in the apk.", item); + var text = Encoding.ASCII.GetString (data); + Assert.AreEqual ("Asset3\n", text, $"The Contents of {item} should be \"Asset3\" but was {text}"); + } + Directory.Delete (Path.Combine (Root, path), recursive: true); + } + + } + [Test] public void CheckAssetsAreIncludedInAPK () { diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 7a971a52255..2a4f86a717f 100755 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -536,7 +536,6 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. $(CoreResolveReferencesDependsOn); - UpdateAndroidAssets; UpdateAndroidInterfaceProxies; UpdateAndroidResources; $(ApplicationResolveReferencesDependsOn); @@ -1907,6 +1906,7 @@ because xbuild doesn't support framework reference assemblies. _CheckDuplicateJavaLibraries; _GetAdditionalResourcesFromAssemblies; _CreateAdditionalResourceCache; + UpdateAndroidAssets; $(_AfterCreateBaseApkDependsOnTargets); <_CreateBaseApkInputs>