Skip to content

Commit 1988dd1

Browse files
authored
Update native-aot.md
1 parent 9540ac8 commit 1988dd1

File tree

1 file changed

+7
-51
lines changed

1 file changed

+7
-51
lines changed

docs/deployment/native-aot.md

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,18 @@ Native AOT compilation provides several advantages specifically relevant to Aval
1717

1818
## Setting Up Native AOT for Avalonia
1919

20-
### 1. Project Configuration
20+
### Project Configuration
2121

2222
Add the following to your csproj file:
2323

2424
```xml
2525
<PropertyGroup>
2626
<PublishAot>true</PublishAot>
27-
<!-- Recommended Avalonia trimming settings for Native AOT -->
27+
<!-- Necessary before Avalonia 12.0, was used for accessiblity APIs -->
2828
<BuiltInComInteropSupport>false</BuiltInComInteropSupport>
29-
<TrimMode>link</TrimMode>
3029
</PropertyGroup>
3130
```
3231

33-
### 2. Trimming Configuration
34-
35-
Native AOT requires trimming. Add these trim settings specific to Avalonia:
36-
37-
```xml
38-
<ItemGroup>
39-
<!-- Preserve Avalonia types for reflection -->
40-
<TrimmerRootAssembly Include="Avalonia.Themes.Fluent" />
41-
<TrimmerRootAssembly Include="Avalonia.Themes.Default" />
42-
</ItemGroup>
43-
```
44-
4532
## Avalonia-Specific Considerations
4633

4734
### XAML Loading
@@ -77,6 +64,7 @@ Intel based macOS
7764
```bash
7865
dotnet publish -r osx-x64 -c Release
7966
```
67+
8068
Apple silicon based macOS
8169
```bash
8270
dotnet publish -r osx-arm64 -c Release
@@ -88,16 +76,8 @@ You can then use Apple's [lipo tool](https://developer.apple.com/documentation/a
8876

8977
## Troubleshooting Common Issues
9078

91-
### 1. Missing XAML Controls
92-
If controls are missing at runtime:
93-
```xml
94-
<ItemGroup>
95-
<!-- Add specific Avalonia controls you're using -->
96-
<TrimmerRootAssembly Include="Avalonia.Controls" />
97-
</ItemGroup>
98-
```
9979

100-
### 2. Reflection-Related Errors
80+
### 1. Reflection-Related Errors
10181
For ViewModels or services using reflection:
10282
```xml
10383
<ItemGroup>
@@ -124,33 +104,9 @@ When using Native AOT with Avalonia, be aware of these limitations:
124104

125105
## Platform Support
126106

127-
| Platform | Status |
128-
|----------|--------|
129-
| Windows x64 | ✅ Supported |
130-
| Windows Arm64 | ✅ Supported |
131-
| Linux x64 | ✅ Supported | |
132-
| Linux Arm64 | ✅ Supported |
133-
| macOS x64 | ✅ Supported | |
134-
| macOS Arm64 | ✅ Supported |
135-
| Browser | ❌ Not Supported |
136-
137-
## Best Practices
138-
139-
1. **Application Structure**
140-
- Use MVVM pattern consistently
141-
- Minimize reflection usage
142-
- Prefer compile-time configuration
143-
144-
2. **Resource Management**
145-
- Use static resources when possible
146-
- Bundle all required assets
147-
- Implement proper cleanup in IDisposable
148-
149-
3. **Performance Optimization**
150-
- Enable binding compilation
151-
- Use compiled bindings
152-
- Implement proper virtualization for large collections
107+
For platform support, please refer to [Platform/architecture restrictions](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/#platformarchitecture-restrictions).
153108

154109
## Additional Resources
155110

156-
- [Avalonia Sample Applications with Native AOT](https://github.com/AvaloniaUI/Avalonia.Samples)
111+
- [Native AOT deployment](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=windows%2Cnet9plus#platformarchitecture-restrictions)
112+
- [Avalonia Sample Applications with Native AOT](https://github.com/AvaloniaUI/Avalonia.Samples)

0 commit comments

Comments
 (0)