Update dotnet-aot-check.yaml #11
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 | ||
|
Check failure on line 1 in .github/workflows/dotnet-aot-check.yaml
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| jobs: | ||
| aot-compile-check: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| # 预定义每个OS对应的runtime和shell,避开三元表达式 | ||
| include: | ||
| - os: windows-latest | ||
| runtime: win-x64 | ||
| shell: pwsh | ||
| - os: ubuntu-latest | ||
| runtime: linux-x64 | ||
| shell: bash | ||
| steps: | ||
| # 步骤1:拉取代码(缩进6个空格,以下步骤统一) | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| # 步骤2:安装.NET SDK(第23行对应这里的dotnet-version) | ||
| - name: Setup .NET SDK | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: # 父级缩进10个空格 | ||
| - '8.0.x' # 数组项缩进12个空格(比父级多2个空格) | ||
| # 步骤3:恢复依赖 | ||
| - name: Restore dependencies | ||
| run: dotnet restore ./src/c#/GeneralUpdate.sln | ||
| # 步骤4:AOT编译检测(用预定义的shell,无三元表达式) | ||
| - name: Check AOT compilation | ||
| shell: ${{ matrix.shell }} | ||
| run: | | ||
| dotnet publish ./src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj \ | ||
| -c Release \ | ||
| -f net8.0 \ | ||
| -r ${{ matrix.runtime }} \ | ||
| --self-contained true \ | ||
| -p:PublishAot=true \ | ||
| -p:EnableCompilationRelaxations=false | ||
| env: | ||
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 | ||
| # 步骤5:验证AOT输出 | ||
| - name: Verify AOT output | ||
| shell: pwsh | ||
| run: | | ||
| $publishDir = "./src/c#/GeneralUpdate.Client/bin/Release/net8.0/${{ matrix.runtime }}/publish" | ||
| if ($env:RUNNER_OS -eq "Windows" -and -not (Test-Path "$publishDir/GeneralUpdate.Client.exe")) { | ||
| throw "AOT executable not found for Windows: $publishDir/GeneralUpdate.Client.exe" | ||
| } | ||
| if ($env:RUNNER_OS -eq "Linux" -and -not (Test-Path "$publishDir/GeneralUpdate.Client")) { | ||
| throw "AOT executable not found for Linux: $publishDir/GeneralUpdate.Client" | ||
| } | ||