[CoreCLR] support MAUI full ReadyToRun - #12299
Conversation
.NET MAUI normally uses partial ReadyToRun with MIBC profiles on Android CoreCLR Release builds. Its new `$(MauiEnableFullReadyToRun)` opt-in removes the partial compilation switch and default profiles. Do not add the generated main-assembly MIBC profile when that opt-in is enabled, so the Android build preserves MAUI's full ReadyToRun request. Document the property and its application-size and performance tradeoffs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e3ea0b-f415-4971-b5b9-55dde11e943e
There was a problem hiding this comment.
Pull request overview
Adds an opt-in hook for .NET MAUI CoreCLR Android apps to switch from MAUI’s default partial ReadyToRun setup (with MIBC profiles) to full ReadyToRun, and documents the new property and its tradeoffs.
Changes:
- Updates CoreCLR ReadyToRun MSBuild logic to skip generating/adding the app main-assembly MIBC profile when
$(MauiEnableFullReadyToRun)is enabled. - Updates build properties documentation to describe
MauiEnableFullReadyToRunbehavior and size/perf implications.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.CoreCLR.targets | Adds an execution-time condition to suppress main-assembly MIBC profile generation when MAUI opts into full ReadyToRun. |
| Documentation/docs-mobile/building-apps/build-properties.md | Documents the new MauiEnableFullReadyToRun property and its tradeoffs. |
Keep `$(MauiEnableFullReadyToRun)` after `$(MandroidI18n)` in the alphabetically sorted build-properties documentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e3ea0b-f415-4971-b5b9-55dde11e943e
Document the `$(PublishReadyToRun)` and `$(PublishReadyToRunComposite)` defaults used by Android CoreCLR Release builds. Explain how `$(UseMonoRuntime)` selects between Mono and CoreCLR, and clarify that `$(RunAOTCompilation)` is specific to Mono AOT. Expand the `$(MauiEnableFullReadyToRun)` guidance and link to the .NET MAUI runtime and compilation overview for broader context. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e3ea0b-f415-4971-b5b9-55dde11e943e
Document that `$(UseMonoRuntime)` defaults to Mono through .NET 10 and to CoreCLR starting in .NET 11. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e3ea0b-f415-4971-b5b9-55dde11e943e
|
|
||
| This MSBuild property is obsolete and is no longer supported. | ||
|
|
||
| ## MauiEnableFullReadyToRun |
There was a problem hiding this comment.
Same as on the MAUI PR:
"MauiEnableFullReadyToRun" sounds a bit clunky, and --partial isn't really specific to Maui anyway.
Maybe a better option would be to introduce a PublishReadyToRunPartial property, which adds --partial to PublishReadyToRunCrossgen2ExtraArgs when true (in dotnet/sdk), and which Android can set to false by default? And then users can do PublishReadyToRunPartial=false to get the full R2R experience.
Either way this is good to me, so I'll approve. FWIW I looked into if we need to do something similar in dotnet/macios, and the answer is no, because we do full R2R by default.
There was a problem hiding this comment.
I think we want to make this MAUI specific for now, since MAUI is right now the only scenario which injects default profile (so the --partial actually does something on its own). The more generic PublichReadyToRunPartial would need to go to SDK (to be correct) and on its own would not function - if we wanted to add this functionality to SDK property, a better design would be to pair it with another property/item group which actually specifies the profiles.
But I'm open to better names (as always, naming is the hardest part).
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ## Description Adds the `MauiEnableFullReadyToRun` MSBuild property for .NET MAUI Android CoreCLR Release builds. Setting the property to `true` opts into full ReadyToRun compilation by omitting MAUI's `--partial` Crossgen2 argument and default MIBC profiles. Leaving it unset or setting it to `false` preserves the existing partial ReadyToRun behavior. Includes workload-neutral MSBuild coverage for the unset, `false`, and `true` cases. Companion PR: dotnet/android#12299 documents the property and excludes the generated main-assembly MIBC profile when full ReadyToRun is enabled. Closes #36587 Copilot-Session: 14d40ad5-6e1e-4491-9965-c95cc93958fe
.NET MAUI uses partial ReadyToRun with default MIBC profiles for Android
CoreCLR Release builds. The companion MAUI change adds
$(MauiEnableFullReadyToRun)and, when enabled, omits the partialcompilation switch and those profiles.
Honor that opt-in in .NET for Android by preventing the generated
main-assembly MIBC profile from being added to the ReadyToRun inputs.
The property is checked directly in the target condition so its value
from MAUI's
buildTransitivetargets is observed at execution time.Expand the build-property reference to document:
$(PublishReadyToRun), including its Android CoreCLRReleasedefault and size/startup tradeoffs.
$(PublishReadyToRunComposite), which defaults totruewhenReadyToRun is enabled.
$(UseMonoRuntime), which selects Mono instead of CoreCLR.$(RunAOTCompilation)as Mono-specific AOT compilation.$(MauiEnableFullReadyToRun), including its partial/full behaviorand size/performance tradeoffs.
The documentation links to the .NET MAUI runtimes and compilation
guide for broader runtime and compilation context.
Issue: dotnet/maui#36587
Companion MAUI PR: dotnet/maui#37094