-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Document NativeAOT support. Fixes #18585. #19362
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
73e3c0f
[docs] Document NativeAOT support. Fixes #18585.
rolfbjarne a3beb93
Update docs/nativeaot.md
rolfbjarne a8bd099
Update docs/nativeaot.md
rolfbjarne a73ea3c
Update docs/nativeaot.md
rolfbjarne b8964e7
Update docs/nativeaot.md
rolfbjarne 461b33e
Misc improvements
rolfbjarne 499a062
Misc improvements
rolfbjarne 17507dc
Update docs/nativeaot.md
rolfbjarne fb8cb38
Reword a bit.
rolfbjarne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# NativeAOT | ||
|
||
We've added *experimental* support for using [NativeAOT][1] when publishing iOS, | ||
tvOS, Mac Catalyst and macOS apps in .NET 8. | ||
|
||
NativeAOT may produce smaller and/or faster apps - or it may not. It's very | ||
important to test and profile to determine the results of enabling NativeAOT. | ||
|
||
However, our initial testing shows significant improvements both in size (up | ||
to 50% smaller) and startup (up to 50% faster). For more information about | ||
performance see [.NET 8 Performance Improvements in .NET MAUI][3]. | ||
|
||
## How to enable NativeAOT? | ||
|
||
rolfbjarne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
NativeAOT is enabled by setting the `PublishAot` property to `true` in the project file: | ||
simonrozsival marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```xml | ||
<PropertyGroup> | ||
<PublishAot>true</PublishAot> | ||
</PropertyGroup> | ||
``` | ||
|
||
## Notes | ||
|
||
NativeAOT is only used when publishing (`dotnet publish`). In particular | ||
`dotnet build -t:Publish` is _not_ equivalent to `dotnet publish`, only | ||
`dotnet publish` will enable NativeAOT. | ||
|
||
**Unsupported** workaround: set the `_IsPublishing` property to `true` to make | ||
`dotnet build` think it's `dotnet publish`: | ||
|
||
```xml | ||
<PropertyGroup> | ||
<PublishAot>true</PublishAot> | ||
<_IsPublishing>true</_IsPublishing> | ||
</PropertyGroup> | ||
``` | ||
|
||
This can be useful to install and run apps with `NativeAOT` from the IDE, | ||
because it's not possible to use `dotnet publish` when running from the IDE. | ||
|
||
rolfbjarne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Compatibility and limitations | ||
|
||
There are no known issues specific to our platforms with NativeAOT; but the | ||
[limitations][2] are exactly the same as for other supported platforms. | ||
|
||
Nevertheless, we would like to point out a few features that are not available | ||
with NativeAOT, that are with Mono, when targeting Apple platforms: | ||
|
||
- NativeAOT does not support managed debugging. | ||
|
||
- There's no interpreter when using NativeAOT, and as such the | ||
`UseInterpreter` and `MtouchInterpreter` properties have no effect. | ||
|
||
- NativeAOT requires trimming, and `MAUI` isn't trimmer-safe, and thus | ||
unfortunately `MAUI` projects don't typically work with NativeAOT (we hope | ||
to rectify this situation for .NET 9). | ||
|
||
[1]: https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot | ||
[2]: https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=net8plus%2Cwindows#limitations-of-native-aot-deployment | ||
[3]: https://devblogs.microsoft.com/dotnet/pending_link_to_blog_post | ||
rolfbjarne marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not exactly confidence inspiring. If I were reading this, I would like to know under what circumstances this would generate larger or slower apps rather than leaving it up to me to profile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately there's no easy way to predict how an app will turn out. The fact that projects are trimmed (linked) means that adding a single line of code somewhere can have a tremendous cascading effect, preventing a lot of other code from being removed. Then add the effect of different AOT compilers (Mono's AOT might generate bigger code in particular when it comes to generics, but there might be other code patterns that may have the opposite effect) multiplied by whatever code patterns is used by all the code that was brought in by that single line of extra code in the project... the answer really is that each project is different, and that developers must test their projects to see the effect of turning on NativeAOT. I'm not sure how to phrase it in a way that inspires more confidence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rolfbjarne maybe something like this might help you phrase it in the right way:
PS I might have some grammatical mistakes as I am not a native speaker, but hope this helps :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it according to Ivan's suggestion, @stephen-hawley does it look better now?