99 matrix :
1010 os : [windows-latest, ubuntu-latest]
1111 runtime : [win-x64, linux-x64]
12- include :
13- - os : windows-latest
14- runtime : win-x64
15- - os : ubuntu-latest
16- runtime : linux-x64
1712
1813 steps :
19- - uses : actions/checkout@v4 # 推荐升级到最新稳定版
14+ - uses : actions/checkout@v4
2015
21- - name : Setup .NET SDK(多版本)
22- uses : actions/setup-dotnet@v4 # 推荐使用 v4 版本,对多SDK支持更友好
23- with :
24- # 正确的数组格式:多个版本放在同一个 dotnet-version 下,用 - 前缀
25- dotnet-version :
26- - ' 8.0.x' # 按需添加需要的 SDK 版本
16+ - name : Setup .NET SDK(多版本)
17+ uses : actions/setup-dotnet@v4
18+ with :
19+ # 关键:数组项必须比 dotnet-version: 多缩进 2 个空格(仅用空格,禁止Tab)
20+ dotnet-version :
21+ - ' 8.0.x'
2722
28- - name : Restore dependencies
29- run : dotnet restore ./src/c#/GeneralUpdate.sln
23+ - name : Restore dependencies
24+ run : dotnet restore ./src/c#/GeneralUpdate.sln
3025
31- - name : Check AOT compilation(指定 net9.0 框架)
32- run : |
33- dotnet publish ./src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj \
34- -c Release \
35- -f net8.0 \ # 显式指定支持 AOT 的框架,避免多框架冲突
36- -r ${{ matrix.runtime }} \
37- --self-contained true \
38- -p:PublishAot=true \
39- -p:EnableCompilationRelaxations=false
40- env :
41- DOTNET_CLI_TELEMETRY_OPTOUT : 1
26+ - name : Check AOT compilation(指定 net8.0 框架)
27+ shell : ${{ matrix.os == 'windows-latest' ? 'pwsh' : 'bash' }}
28+ run : |
29+ dotnet publish ./src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj \
30+ -c Release \
31+ -f net8.0 \
32+ -r ${{ matrix.runtime }} \
33+ --self-contained true \
34+ -p:PublishAot=true \
35+ -p:EnableCompilationRelaxations=false
36+ env :
37+ DOTNET_CLI_TELEMETRY_OPTOUT : 1
38+
39+ - name : Verify AOT output
40+ shell : pwsh
41+ run : |
42+ $publishDir = "./src/c#/GeneralUpdate.Client/bin/Release/net8.0/${{ matrix.runtime }}/publish"
43+ if ($env:RUNNER_OS -eq "Windows" -and -not (Test-Path "$publishDir/GeneralUpdate.Client.exe")) {
44+ throw "AOT compiled executable not found for Windows: $publishDir/GeneralUpdate.Client.exe"
45+ }
46+ if ($env:RUNNER_OS -eq "Linux" -and -not (Test-Path "$publishDir/GeneralUpdate.Client")) {
47+ throw "AOT compiled executable not found for Linux: $publishDir/GeneralUpdate.Client"
48+ }
0 commit comments