Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] ReOrder when Assets are Processed. #1161

Merged
merged 1 commit into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name=""CustomTarget"" AfterTargets=""Compile"" >
<WriteLinesToFile
File=""Assets\\asset3.txt""
Lines=""Asset3""
Overwrite=""true""/>
</Target>
</Project>"
},
},

};
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 ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
</CoreResolveReferencesDependsOn>
<ResolveReferencesDependsOn>
$(CoreResolveReferencesDependsOn);
UpdateAndroidAssets;
UpdateAndroidInterfaceProxies;
UpdateAndroidResources;
$(ApplicationResolveReferencesDependsOn);
Expand Down Expand Up @@ -1907,6 +1906,7 @@ because xbuild doesn't support framework reference assemblies.
_CheckDuplicateJavaLibraries;
_GetAdditionalResourcesFromAssemblies;
_CreateAdditionalResourceCache;
UpdateAndroidAssets;
$(_AfterCreateBaseApkDependsOnTargets);
</_CreateBaseApkDependsOnTargets>
<_CreateBaseApkInputs>
Expand Down