Removed Immediate.Apis, Added AOT Testing Scripts.
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
# 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:**
|
||||
```powershell
|
||||
.\build-aot.ps1
|
||||
```
|
||||
|
||||
**Build Only:**
|
||||
```powershell
|
||||
.\build-aot.ps1 -BuildOnly
|
||||
```
|
||||
|
||||
**Run Only (if already built):**
|
||||
```powershell
|
||||
.\build-aot.ps1 -RunOnly
|
||||
```
|
||||
|
||||
### Linux/POP_OS (Bash)
|
||||
|
||||
Make the script executable first:
|
||||
```bash
|
||||
chmod +x build-aot.sh
|
||||
```
|
||||
|
||||
**Build and Run:**
|
||||
```bash
|
||||
./build-aot.sh
|
||||
```
|
||||
|
||||
**Build Only:**
|
||||
```bash
|
||||
./build-aot.sh --build-only
|
||||
```
|
||||
|
||||
**Run Only (if already built):**
|
||||
```bash
|
||||
./build-aot.sh --run-only
|
||||
```
|
||||
|
||||
## What These Scripts Do
|
||||
|
||||
1. **Clean**: Removes any previous publish directory
|
||||
2. **Build**: Publishes the application with the following AOT settings:
|
||||
- `PublishAot=true` - Enables AOT compilation
|
||||
- `TrimMode=link` - Uses link-time trimming
|
||||
- `PublishTrimmed=true` - Enables trimming
|
||||
- `SelfContained=true` - Creates a self-contained executable
|
||||
- Debug symbols are disabled for optimized output
|
||||
|
||||
3. **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
|
||||
|
||||
1. **"Executable not found"**: The build may have failed silently. Check the build output for errors.
|
||||
2. **Runtime crashes**: Trimming may have removed necessary code. Consider adding trimming configuration in your project file or using `[DynamicallyAccessedMembers]` attributes.
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [AOT Deployment](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/)
|
||||
- [Trimming .NET Applications](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained)
|
||||
- [Reflections and Trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained#reflections)
|
||||
Reference in New Issue
Block a user