Update dotnet-aot-check.yaml #14
This file contains hidden or 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
| name: Check AOT Support | |
| on: [push, pull_request] | |
| jobs: | |
| check-aot: | |
| runs-on: windows-latest # 也可使用 ubuntu-latest 或 macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' # 需使用支持AOT的.NET版本(.NET 7+) | |
| - name: Restore dependencies | |
| run: dotnet restore ./src/c#/GeneralUpdate.sln | |
| - name: Check AOT compatibility | |
| run: | | |
| # 尝试以AOT模式发布项目(以控制台应用为例) | |
| dotnet publish ./src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj ` | |
| -c Release ` | |
| -r win-x64 ` # 根据运行系统选择运行时标识符(如 linux-x64、osx-x64) | |
| -p:PublishAot=true ` | |
| --self-contained true | |
| continue-on-error: true # 允许命令失败,后续通过日志判断结果 | |
| - name: Analyze result | |
| run: | | |
| # 检查上一步骤的退出码,0表示AOT编译成功,非0表示不支持 | |
| if ($LASTEXITCODE -eq 0) { | |
| Write-Host "✅ 项目支持AOT编译" | |
| } else { | |
| Write-Host "❌ 项目不支持AOT编译,请检查错误日志" | |
| exit 1 # 若需要严格检测,可在此处让Workflow失败 | |
| } |