2.7 KiB
2.7 KiB
AOT Testing Guide
This directory contains scripts for building and testing the Htmx.ApiDemo application with Ahead-of-Time (AOT) compilation enabled. AOT compilation helps identify potential trimming issues that may occur at runtime.
Directory Structure
Testing/
└── AOT/
├── build-aot.ps1 # Windows PowerShell script
├── build-aot.sh # Linux/POP_OS bash script
├── Publish/ # Output directory (created during build)
└── README.md # This file
Prerequisites
- .NET SDK (version 10.0 or later)
- For Windows: PowerShell 5.1 or later
- For Linux/POP_OS: Bash shell
Usage
Windows (PowerShell)
Build and Run:
.\build-aot.ps1
Build Only:
.\build-aot.ps1 -BuildOnly
Run Only (if already built):
.\build-aot.ps1 -RunOnly
Linux/POP_OS (Bash)
Make the script executable first:
chmod +x build-aot.sh
Build and Run:
./build-aot.sh
Build Only:
./build-aot.sh --build-only
Run Only (if already built):
./build-aot.sh --run-only
What These Scripts Do
-
Clean: Removes any previous publish directory
-
Build: Publishes the application with the following AOT settings:
PublishAot=true- Enables AOT compilationTrimMode=link- Uses link-time trimmingPublishTrimmed=true- Enables trimmingSelfContained=true- Creates a self-contained executable- Debug symbols are disabled for optimized output
-
Run: Launches the compiled application to test for any trimming-related issues
Output
The compiled application and all dependencies are published to the Testing/AOT/Publish directory.
Troubleshooting
Build Failures
If the AOT build fails, check the error messages for:
- Trimming issues: Indicates code that cannot be safely trimmed
- Reflection warnings: APIs that use reflection may not work properly
- Missing dependencies: Required libraries that aren't properly configured
Common Issues
- "Executable not found": The build may have failed silently. Check the build output for errors.
- Runtime crashes: Trimming may have removed necessary code. Consider adding trimming configuration in your project file or using
[DynamicallyAccessedMembers]attributes.