diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/in/Microsoft.Android.Sdk.BundledVersions.in.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/in/Microsoft.Android.Sdk.BundledVersions.in.targets
index 2d4ebccd929..13b1aec9b67 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/in/Microsoft.Android.Sdk.BundledVersions.in.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/in/Microsoft.Android.Sdk.BundledVersions.in.targets
@@ -20,7 +20,6 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<_AndroidTargetingPackId Condition=" '$(_AndroidTargetingPackId)' != '$(_AndroidLatestStableApiLevel)' and '$(_AndroidTargetingPackId)' != '$(_AndroidLatestUnstableApiLevel)' ">$(_AndroidLatestStableApiLevel)
<_AndroidRuntimePackId Condition=" '$(_AndroidRuntimePackId)' == '' ">$(_AndroidTargetingPackId)
<_AndroidRuntimePackId Condition=" '$(_AndroidRuntimePackId)' != '$(_AndroidLatestStableApiLevel)' and '$(_AndroidRuntimePackId)' != '$(_AndroidLatestUnstableApiLevel)' ">$(_AndroidLatestStableApiLevel)
- <_AndroidRuntimePackRuntime Condition=" '$(PublishAot)' == 'true' ">NativeAOT
<_AndroidRuntimePackRuntime Condition=" '$(_AndroidRuntimePackRuntime)' == '' ">Mono
diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
index d10521b1b97..d4e0572ee41 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
@@ -24,10 +24,13 @@
See: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L16
-->
<_GetChildProjectCopyToPublishDirectoryItems>false
- false
+
+ <_AndroidNativeAot Condition=" '$(PublishAot)' == 'true' ">true
+ <_AndroidNativeAot Condition=" '$(_AndroidNativeAot)' == '' ">false
+ false
true
- <_IsPublishing Condition=" '$(_IsPublishing)' == '' and '$(PublishAot)' == 'true' ">true
+ <_IsPublishing Condition=" '$(_IsPublishing)' == '' and '$(_AndroidNativeAot)' == 'true' ">true
$(AndroidMinimumSupportedApiLevel)
@@ -94,7 +97,7 @@
true
- true
+ true
true
false
<_AndroidXA1029 Condition=" '$(AotAssemblies)' != '' ">true
diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets
index 78cb1632cea..8f0d03ac750 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets
@@ -7,6 +7,11 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
-->
+
+
+ <_AndroidRuntimePackRuntime>NativeAOT
+
+
@@ -60,12 +65,17 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
$(_OriginalSuppressTrimAnalysisWarnings)
+
+
+ <_AndroidILLinkAssemblies Include="@(ManagedAssemblyToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" Condition="Exists('$(IntermediateLinkDir)%(Filename)%(Extension)')" />
-
+
+
+
@@ -76,4 +86,11 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
+
+
+
+
+
+
+
diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.targets
index 16610e6db82..31755d131e8 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.targets
@@ -27,6 +27,6 @@
-
+
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs
index 7c13c195b16..18b5543e252 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs
@@ -93,6 +93,8 @@ public class GenerateJavaStubs : AndroidTask
[Output]
public ITaskItem[] GeneratedBinaryTypeMaps { get; set; }
+ public bool NativeAot { get; set; }
+
internal const string AndroidSkipJavaStubGeneration = "AndroidSkipJavaStubGeneration";
public override bool RunTask ()
@@ -294,6 +296,11 @@ Dictionary MaybeGetArchAssemblies (Dictionary additionalProviders)
{
+ if (NativeAot) {
+ Log.LogDebugMessage ("Skipping MonoRuntimeProvider generation for NativeAot");
+ return;
+ }
+
// Create additional runtime provider java sources.
string providerTemplateFile = "MonoRuntimeProvider.Bundled.java";
string providerTemplate = GetResource (providerTemplateFile);
@@ -347,6 +354,7 @@ IList MergeManifest (NativeCodeGenState codeGenState, Dictionary", "()V", dexFile, AndroidSdkPath), $"`{dexFile}` should *not* include `{className}`!");
+ }
+
+ var apkFile = Path.Combine (output, $"{proj.PackageName}-Signed.apk");
+ FileAssert.Exists (apkFile);
+ using var zip = ZipHelper.OpenZip (apkFile);
+ foreach (var mono_file in mono_files) {
+ Assert.IsFalse (zip.ContainsEntry (mono_file, caseSensitive: true), $"APK must *not* contain `{mono_file}`.");
+ }
+ foreach (var nativeaot_file in nativeaot_files) {
+ Assert.IsTrue (zip.ContainsEntry (nativeaot_file, caseSensitive: true), $"APK must contain `{nativeaot_file}`.");
+ }
}
[Test]
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidApplicationProject.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidApplicationProject.cs
index 68416ad4831..7cf28b8ace0 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidApplicationProject.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidApplicationProject.cs
@@ -134,6 +134,11 @@ public bool UseJackAndJill {
set { SetProperty (KnownProperties.UseJackAndJill, value.ToString ()); }
}
+ public string RuntimeIdentifier {
+ get { return GetProperty (KnownProperties.RuntimeIdentifier); }
+ set { SetProperty (KnownProperties.RuntimeIdentifier, value); }
+ }
+
public AndroidLinkMode AndroidLinkModeDebug {
get {
AndroidLinkMode m;
diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs b/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs
index 50e1e71e3f9..41d97ae3c32 100644
--- a/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs
+++ b/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs
@@ -94,6 +94,7 @@ internal class ManifestDocument
public bool ForceDebuggable { get; set; }
public string VersionName { get; set; }
public IVersionResolver VersionResolver { get; set; } = new MonoAndroidHelperVersionResolver ();
+ public bool NativeAot { get; set; }
string versionCode;
@@ -672,6 +673,11 @@ XElement CreateApplicationElement (XElement manifest, string applicationClass, L
IList AddMonoRuntimeProviders (XElement app)
{
+ if (NativeAot) {
+ //TODO: implement NativeAOT provider logic
+ return [];
+ }
+
app.Add (CreateMonoRuntimeProvider ("mono.MonoRuntimeProvider", null, --AppInitOrder));
var providerNames = new List ();
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
index a42b16360d4..e57e77ea773 100644
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
@@ -324,9 +324,9 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
true
True
False
- True
+ True
- False
+ False
<_AndroidUseMarshalMethods Condition=" '$(AndroidIncludeDebugSymbols)' == 'True' ">False
<_AndroidUseMarshalMethods Condition=" '$(AndroidIncludeDebugSymbols)' != 'True' ">$(AndroidEnableMarshalMethods)
@@ -1374,6 +1374,7 @@ because xbuild doesn't support framework reference assemblies.
DependsOnTargets="_CollectRuntimeJarFilenames;$(_BeforeAddStaticResources);_GetMonoPlatformJarPath">
@@ -1492,6 +1493,7 @@ because xbuild doesn't support framework reference assemblies.
@@ -1939,7 +1942,7 @@ because xbuild doesn't support framework reference assemblies.