Skip to content

Guard Mono-specific AOT targets for CoreCLR runtime, add XA1042 warning#11070

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-mono-targets-with-coreclr
Draft

Guard Mono-specific AOT targets for CoreCLR runtime, add XA1042 warning#11070
Copilot wants to merge 2 commits intomainfrom
copilot/fix-mono-targets-with-coreclr

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

Setting <RunAOTCompilation>true</RunAOTCompilation> in a project file (e.g. Directory.Build.props) causes build failures when switching from Mono to CoreCLR, because MonoAOTCompiler runs unconditionally regardless of the active runtime.

Changes

  • Microsoft.Android.Sdk.Aot.targets — Add '$(_AndroidRuntime)' == 'MonoVM' guard to the ImportGroup (MonoAOTCompiler SDK imports) and _AndroidAot target condition
  • Microsoft.Android.Sdk.DefaultProperties.targets — After RunAOTCompilation defaults are resolved, detect Mono-specific properties (RunAOTCompilation, EnableLLVM) set with non-MonoVM runtimes, reset them to false, and set flags for warning emission
  • Xamarin.Android.Common.targets — Emit new XA1042 warning when the flags are set
  • Resources.resx / Resources.Designer.cs — New XA1042 message
  • xa1042.md — Documentation for the new warning
  • AotTests.cs — Two tests: RunAOTCompilationWithCoreClrWarnsAndSkipsMonoAot and EnableLLVMWithCoreClrWarnsAndIsIgnored

Example warning

warning XA1042: The MSBuild property 'RunAOTCompilation' is not compatible with the CoreCLR runtime and will be ignored.
Either remove the property or guard it with a condition: Condition="'$(UseMonoRuntime)' == 'true'"

Migration guidance

<!-- Before: breaks when switching to CoreCLR -->
<RunAOTCompilation>true</RunAOTCompilation>

<!-- After: only applies to Mono -->
<PropertyGroup Condition=" '$(UseMonoRuntime)' == 'true' ">
  <RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>

…r Mono-specific properties used with non-MonoVM runtimes

Agent-Logs-Url: https://github.com/dotnet/android/sessions/a5ac81b3-0cd5-4a8a-9394-531fa1466274

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Mono targets execution when using CoreCLR runtime Guard Mono-specific AOT targets for CoreCLR runtime, add XA1042 warning Apr 2, 2026
Copilot AI requested a review from simonrozsival April 2, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CoreCLR] Setting RunAOTCompilation in project file runs MonoAOTCompiler even with CoreCLR runtime

2 participants