Skip to content
Draft
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 @@ -13,8 +13,8 @@ This file contains the CoreCLR-specific MSBuild logic for .NET for Android.
</PropertyGroup>
<!-- Properties for $(OutputType)=Exe (Android Applications) -->
<PropertyGroup Condition=" '$(AndroidApplication)' == 'true' ">
<!-- Default to R2R Composite for CoreCLR Release mode -->
<PublishReadyToRun Condition=" '$(PublishReadyToRun)' == '' and '$(Configuration)' == 'Release' ">true</PublishReadyToRun>
<!-- Default to R2R Composite for CoreCLR Release mode or when publishing -->
<PublishReadyToRun Condition=" '$(PublishReadyToRun)' == '' and ('$(Configuration)' == 'Release' or '$(_IsPublishing)' == 'true') ">true</PublishReadyToRun>
<PublishReadyToRunComposite Condition=" '$(PublishReadyToRunComposite)' == '' and '$(PublishReadyToRun)' == 'true' ">true</PublishReadyToRunComposite>
<_IsPublishing Condition=" '$(_IsPublishing)' == '' and '$(PublishReadyToRun)' == 'true' ">true</_IsPublishing>
<AllowReadyToRunWithoutRuntimeIdentifier Condition=" '$(PublishReadyToRun)' == 'true' and '$(RuntimeIdentifiers)' != '' ">true</AllowReadyToRunWithoutRuntimeIdentifier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,36 @@ public void BasicApplicationPublishReadyToRun ([Values] bool isComposite, [Value
$"ReadyToRun image not found in {assemblyName}.dll! ManagedNativeHeaderDirectory should not be empty!");
}

[Test]
public void PublishReadyToRunCustomConfiguration ([Values ("android-arm64")] string rid)
{
var proj = new XamarinAndroidApplicationProject (releaseConfigurationName: "CustomRelease") {
IsRelease = true, // Uses "CustomRelease" as the configuration, not "Release"
};

proj.SetRuntime (AndroidRuntime.CoreCLR);
proj.SetProperty ("RuntimeIdentifier", rid);
proj.SetProperty ("AndroidEnableAssemblyCompression", "false");
proj.SetProperty ("_IsPublishing", "true"); // Simulates `dotnet publish`

var b = CreateApkBuilder ();
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");

var assemblyName = proj.ProjectName;
var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, rid, $"{proj.PackageName}-Signed.apk");
FileAssert.Exists (apk);

var helper = new ArchiveAssemblyHelper (apk, true);
var abi = MonoAndroidHelper.RidToAbi (rid);
Assert.IsTrue (helper.Exists ($"assemblies/{abi}/{assemblyName}.dll"), $"{assemblyName}.dll should exist in apk!");

using var stream = helper.ReadEntry ($"assemblies/{assemblyName}.dll");
stream.Position = 0;
using var peReader = new System.Reflection.PortableExecutable.PEReader (stream);
Assert.IsTrue (peReader.PEHeaders.CorHeader.ManagedNativeHeaderDirectory.Size > 0,
$"ReadyToRun image not found in {assemblyName}.dll! ManagedNativeHeaderDirectory should not be empty!");
}

[Test]
public void NativeAOT ()
{
Expand Down