Update dotnet-aot-check.yaml #6
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: dotnet-aot-check | ||
| on: [pull_request, push] | ||
| jobs: | ||
| aot-compile-check: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [windows-latest, ubuntu-latest] | ||
| runtime: [win-x64, linux-x64] | ||
| include: | ||
| - os: windows-latest | ||
| runtime: win-x64 | ||
| - os: ubuntu-latest | ||
| runtime: linux-x64 | ||
| steps: | ||
| - uses: actions/checkout@v4 # 推荐升级到最新稳定版 | ||
| - name: Setup .NET SDK(多版本) | ||
| uses: actions/setup-dotnet@v4 # 推荐使用 v4 版本,对多SDK支持更友好 | ||
| with: | ||
| # 正确的数组格式:多个版本放在同一个 dotnet-version 下,用 - 前缀 | ||
| dotnet-version: | ||
| - '8.0.x' # 按需添加需要的 SDK 版本 | ||
| - name: Restore dependencies | ||
| run: dotnet restore ./src/c#/GeneralUpdate.sln | ||
| - name: Check AOT compilation(指定 net9.0 框架) | ||
| run: | | ||
| dotnet publish ./src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj \ | ||
| -c Release \ | ||
| -f net8.0 \ # 显式指定支持 AOT 的框架,避免多框架冲突 | ||
| -r ${{ matrix.runtime }} \ | ||
| --self-contained true \ | ||
| -p:PublishAot=true \ | ||
| -p:EnableCompilationRelaxations=false | ||
| env: | ||
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 | ||
| - name: Verify AOT output | ||
| run: | | ||
| $publishDir = "./src/c#/GeneralUpdate.Client/bin/Release/net9.0/${{ matrix.runtime }}/publish" | ||
| if ($env:RUNNER_OS -eq "Windows" -and -not (Test-Path "$publishDir/GeneralUpdate.Client.exe")) { | ||
| throw "AOT compiled executable not found for Windows" | ||
| } | ||
| if ($env:RUNNER_OS -eq "Linux" -and -not (Test-Path "$publishDir/GeneralUpdate.Client")) { | ||
| throw "AOT compiled executable not found for Linux" | ||
| } | ||
| shell: pwsh | ||