diff --git a/Documentation/guides/messages/xa1030.md b/Documentation/guides/messages/xa1030.md
new file mode 100644
index 00000000000..c84217c25b6
--- /dev/null
+++ b/Documentation/guides/messages/xa1030.md
@@ -0,0 +1,37 @@
+---
+title: Xamarin.Android error XA1030
+description: XA1030 error code
+ms.date: 09/26/2022
+---
+# Xamarin.Android error XA1030
+
+## Example messages
+
+```
+The 'RunAOTCompilation' MSBuild property is only supported when trimming is enabled. Edit the project file in a text editor to set 'PublishTrimmed' to 'true' for this build configuration.
+```
+
+## Solution
+
+Instead of using:
+
+```xml
+
+ true
+
+ false
+ None
+
+```
+
+Use the default value for `$(PublishTrimmed)` and `$(AndroidLinkMode)`
+instead:
+
+```xml
+
+ true
+
+```
+
+Additionally, as mentioned by [`XA0119`](xa0119.md), you should not
+use `$(RunAOTCompilation)` in `Debug` configurations.
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 a1692029bbf..2d83fb1ef7d 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
@@ -79,6 +79,7 @@
true
false
<_AndroidXA1029 Condition=" '$(AotAssemblies)' != '' ">true
+ <_AndroidXA1030 Condition=" '$(RunAOTCompilation)' == 'true' and '$(PublishTrimmed)' == 'false' ">true
$(RunAOTCompilation)
true
diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
index 509fe13fdfc..55e9040f419 100644
--- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
+++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
@@ -466,6 +466,10 @@ In this message, the term "binding" means a piece of generated code that makes i
The 'AotAssemblies' MSBuild property is deprecated. Edit the project file in a text editor to remove this property, and use the 'RunAOTCompilation' MSBuild property instead.
The following are literal names and should not be translated: 'AotAssemblies', 'RunAOTCompilation'
+
+ The 'RunAOTCompilation' MSBuild property is only supported when trimming is enabled. Edit the project file in a text editor to set 'PublishTrimmed' to 'true' for this build configuration.
+ The following are literal names and should not be translated: 'RunAOTCompilation', 'PublishTrimmed'
+
Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in Xamarin.Android once .NET 6 is released.
The following are literal names and should not be translated: AppDomain.CreateDomain(), AppDomain
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs
index 6d9dd27d5c7..bb009c736de 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs
@@ -1103,6 +1103,7 @@ public void BenchmarkDotNet ()
/* useInterpreter */ true,
/* publishTrimmed */ true,
/* aot */ true,
+ /* expected */ true,
},
// Debug + AOT
new object [] {
@@ -1110,6 +1111,7 @@ public void BenchmarkDotNet ()
/* useInterpreter */ false,
/* publishTrimmed */ true,
/* aot */ true,
+ /* expected */ true,
},
// Debug + PublishTrimmed
new object [] {
@@ -1117,12 +1119,21 @@ public void BenchmarkDotNet ()
/* useInterpreter */ false,
/* publishTrimmed */ true,
/* aot */ false,
+ /* expected */ true,
+ },
+ // AOT + PublishTrimmed=false
+ new object [] {
+ /* isRelease */ true,
+ /* useInterpreter */ false,
+ /* publishTrimmed */ false,
+ /* aot */ true,
+ /* expected */ false,
},
};
[Test]
[TestCaseSource (nameof (SettingCombinationsSource))]
- public void SettingCombinations (bool isRelease, bool useInterpreter, bool publishTrimmed, bool aot)
+ public void SettingCombinations (bool isRelease, bool useInterpreter, bool publishTrimmed, bool aot, bool expected)
{
var proj = new XASdkProject {
IsRelease = isRelease,
@@ -1131,7 +1142,7 @@ public void SettingCombinations (bool isRelease, bool useInterpreter, bool publi
proj.SetProperty ("PublishTrimmed", publishTrimmed.ToString ());
proj.SetProperty ("RunAOTCompilation", aot.ToString ());
var builder = CreateDotNetBuilder (proj);
- Assert.IsTrue (builder.Build (), $"{proj.ProjectName} should succeed");
+ Assert.AreEqual (expected, builder.Build (), $"{proj.ProjectName} should {(expected ? "succeed" : "fail")}");
}
DotNetCLI CreateDotNetBuilder (string relativeProjectDir = null)
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
index 7124a4681ba..ff4261ab71c 100644
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
@@ -516,6 +516,10 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
ResourceName="XA1029"
Condition=" $(_AndroidXA1029) == 'true' "
/>
+