You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[build] make TrimMode=full function like NativeAOT (#22282)
Context: dotnet/android#8805
Context: dotnet/macios#20354
In .NET 9, we want .NET MAUI applications to be able to use the
`TrimMode=full` option to remove unused code from the application:
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TrimMode>full</TrimMode>
</PropertyGroup>
With all the trimming work done to support NativeAOT, we should toggle
the same options when `TrimMode=full` is used:
* `MauiStrictXamlCompilation=true`
* `MauiXamlRuntimeParsingSupport=false`
* `MauiShellSearchResultsRendererDisplayMemberNameSupported=false`
* `MauiQueryPropertyAttributeSupport=false`
* `MauiImplicitCastOperatorsUsageViaReflectionSupport=false`
With these set, the `dotnet new maui` project template *should* have
zero trimmer warnings when `TrimMode=full` is used. Developers can also
adjust these settings and respond to trimmer warnings in their own code.
I also updated `RunOnAndroid` and `RunOniOS` tests to verify that
project templates launch successfully with `TrimMode=full`.
Note:
* Skip `maui-blazor` on iOS for now, as it contains trimmer warnings.
Copy file name to clipboardExpand all lines: docs/design/FeatureSwitches.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
Certain features of MAUI can be enabled or disabled using feature switches. The easiest way to control the features is by putting the corresponding MSBuild property into the app's project file. Disabling unnecessary features can help reducing the app size when combined with the [`full` trimming mode](https://learn.microsoft.com/dotnet/core/deploying/trimming/trimming-options).
4
4
5
+
The following switches are toggled for applications running on Mono for `TrimMode=full` as well as NativeAOT.
6
+
5
7
| MSBuild Property Name | AppContext Setting | Description |
6
8
|-|-|-|
7
9
| MauiXamlRuntimeParsingSupport | Microsoft.Maui.RuntimeFeature.IsXamlRuntimeParsingSupported | When disabled, all XAML loading at runtime will throw an exception. This will affect usage of APIs such as the `LoadFromXaml` extension method. This feature can be safely turned off when all XAML resources are compiled using XamlC (see [XAML compilation](https://learn.microsoft.com/dotnet/maui/xaml/xamlc)). This feature is enabled by default for all configurations except for NativeAOT. |
buildProps.Add("IlcTreatWarningsAsErrors=false");// TODO: Remove this once all warnings are fixed https://github.com/dotnet/maui/issues/19397
0 commit comments