| name | dotnet-aot-analysis |
| description | Analyzes and configures a .NET project or solution for Native AOT compatibility. Orchestrates source generator skills and applies AOT settings. Also use when the user mentions "AOT," "native AOT," "trimming," "publish AOT," "AOT compatibility," or "ahead-of-time compilation." For specific source generators, see dotnet-source-gen-json, dotnet-source-gen-regex, dotnet-source-gen-logging. |
| license | MIT |
| metadata | {"author":"Im5tu","version":"1.0","repositoryUrl":"https://github.com/im5tu/dotnet-skills"} |
| allowed-tools | Bash(dotnet:*) Read Glob Grep AskUserQuestion |
Analyze and configure a .NET project or solution for Native AOT compatibility, applying source generators and AOT settings.
When to Use
- User wants to enable Native AOT
- User wants to check AOT compatibility
- User wants to optimize for AOT deployment
Workflow
Step 1: Ask Scope
Ask user: Solution-wide or Specific project(s)?
Step 2: Detect Project Types
For each project:
- Check for ASP.NET Core (
Microsoft.AspNetCore refs, WebApplication, CreateBuilder)
- Check for Blazor Server (
Microsoft.AspNetCore.Components.Server)
- Check for MVC (
AddControllersWithViews, AddMvc)
Step 3: Warn About Unsupported Scenarios
Ask user: Continue with compatible projects or abort?
Step 4: Invoke Sub-Skills
For each compatible project, invoke:
dotnet-source-gen-json - JSON serialization AOT readiness (includes polymorphic types)
dotnet-source-gen-options-validation - Options pattern AOT readiness
dotnet-source-gen-regex - Regex AOT readiness
dotnet-source-gen-logging - Logging AOT readiness
Step 5: Configure AOT Settings
If solution-wide:
Check for src/Directory.Build.props, otherwise use solution root. Add/merge:
<Project>
<PropertyGroup>
<IsAotCompatible>true</IsAotCompatible>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
<EnableAotAnalyzer>true</EnableAotAnalyzer>
</PropertyGroup>
</Project>
If project-specific:
Add to each .csproj:
<PropertyGroup>
<PublishAot>true</PublishAot>
</PropertyGroup>
Step 6: ASP.NET Core Specific
For ASP.NET Core projects:
Step 7: Verify
Run dotnet build and check for AOT warnings.
Key Documentation Links
Notes
- Requires .NET 8+
- ASP.NET Core: Use
CreateSlimBuilder() for optimal size
- Minimal APIs: Enable Request Delegate Generator (RDG) for optimal AOT performance
- Eliminate runtime reflection from hot paths; use source generators where reflection would otherwise be required
- System.Text.Json: Register all types in
JsonSerializerContext