Skip to content

Commit 54cf979

Browse files
HanFengRuYueclaude
andcommitted
fix: 修复 Updater AOT 构建在 Start-Job 子进程中失败的问题
将 Updater AOT 构建从 Start-Job 后台任务移回独立的 GitHub Actions step。 AOT 编译需要 Visual Studio 原生工具链(link.exe),Start-Job 创建的子进程 可能缺少 VS 环境变量导致链接失败。同时改进 TranslatorEndpoint 的 Receive-Job 错误处理,防止终止性错误吞掉构建输出。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent aeb3a88 commit 54cf979

2 files changed

Lines changed: 26 additions & 33 deletions

File tree

.github/workflows/build.yml

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Optimizations over naive sequential build:
55
# - NuGet package cache (actions/cache)
66
# - npm ci runs in parallel with bundled asset downloads + dotnet restore
7-
# - Frontend build, Updater AOT, and TranslatorEndpoint build run in parallel
7+
# - Frontend build and TranslatorEndpoint build run in parallel; Updater AOT runs as a separate step
88
# - Main release ZIP created in parallel with component ZIPs
99
# - Component ZIPs use direct entry creation (no temp directory copies)
1010
name: Build
@@ -13,7 +13,7 @@ on:
1313
workflow_call:
1414
inputs:
1515
build_version:
16-
description: 'Version string (e.g. 1.6.202603130200); auto-generated if empty'
16+
description: 'Version string (e.g. 1.7.202603130200); auto-generated if empty'
1717
required: false
1818
type: string
1919
release_tag:
@@ -348,23 +348,17 @@ jobs:
348348
Remove-Job $npmCiJob
349349
Write-Host "npm ci complete."
350350
351-
# ── Parallel: Build frontend + Updater AOT + TranslatorEndpoint ──
352-
# Frontend build runs in foreground (longest, shows progress live).
353-
# Updater AOT and TranslatorEndpoint run in background via Start-Job.
351+
# ── Build frontend & TranslatorEndpoint (parallel) ──
352+
# Frontend runs in foreground (longest, shows progress live).
353+
# TranslatorEndpoint runs in background via Start-Job.
354+
# Updater AOT is a separate step — AOT needs native toolchain
355+
# which is unreliable inside Start-Job child processes.
354356

355-
- name: Build frontend, Updater & TranslatorEndpoint
357+
- name: Build frontend & TranslatorEndpoint
356358
shell: pwsh
357359
run: |
358360
$workDir = $PWD.Path
359361
360-
# Start Updater AOT publish in background
361-
$updaterJob = Start-Job -ScriptBlock {
362-
param($dir)
363-
Set-Location $dir
364-
& dotnet publish Updater/Updater.csproj -c Release -r win-x64 --no-restore 2>&1
365-
if ($LASTEXITCODE -ne 0) { throw "Updater AOT build failed (exit code $LASTEXITCODE)" }
366-
} -ArgumentList $workDir
367-
368362
# Start TranslatorEndpoint build in background (conditional on XUnity DLLs)
369363
$endpointJob = $null
370364
$hasLibs = (Test-Path "TranslatorEndpoint/libs/XUnity.AutoTranslator.Plugin.Core.dll") -and
@@ -389,33 +383,22 @@ jobs:
389383
Write-Host "::endgroup::"
390384
391385
if ($frontendExit -ne 0) {
392-
$updaterJob | Stop-Job -PassThru | Remove-Job -Force
393386
if ($endpointJob) { $endpointJob | Stop-Job -PassThru | Remove-Job -Force }
394387
throw "Frontend build failed"
395388
}
396389
Write-Host "Frontend build complete."
397390
398-
# Collect Updater AOT results
399-
Write-Host "::group::Updater AOT Build"
400-
$updaterJob | Wait-Job | Out-Null
401-
$updaterOutput = Receive-Job $updaterJob 2>&1
402-
if ($updaterOutput) { $updaterOutput | ForEach-Object { Write-Host $_ } }
403-
if ($updaterJob.State -eq 'Failed') {
404-
$err = $updaterJob.ChildJobs[0].JobStateInfo.Reason.Message
405-
Remove-Job $updaterJob -Force
406-
if ($endpointJob) { $endpointJob | Stop-Job -PassThru | Remove-Job -Force }
407-
throw "Updater AOT build failed: $err"
408-
}
409-
Remove-Job $updaterJob -Force
410-
Write-Host "Updater build complete."
411-
Write-Host "::endgroup::"
412-
413391
# Collect TranslatorEndpoint results
414392
if ($endpointJob) {
415393
Write-Host "::group::TranslatorEndpoint Build"
416394
$endpointJob | Wait-Job | Out-Null
417-
$endpointOutput = Receive-Job $endpointJob 2>&1
418-
if ($endpointOutput) { $endpointOutput | ForEach-Object { Write-Host $_ } }
395+
try {
396+
$endpointOutput = Receive-Job $endpointJob -ErrorAction Stop 2>&1
397+
if ($endpointOutput) { $endpointOutput | ForEach-Object { Write-Host $_ } }
398+
} catch {
399+
$endpointOutput = Receive-Job $endpointJob -ErrorAction SilentlyContinue 2>&1
400+
if ($endpointOutput) { $endpointOutput | ForEach-Object { Write-Host $_ } }
401+
}
419402
if ($endpointJob.State -eq 'Failed') {
420403
$err = $endpointJob.ChildJobs[0].JobStateInfo.Reason.Message
421404
Remove-Job $endpointJob -Force
@@ -426,6 +409,16 @@ jobs:
426409
Write-Host "::endgroup::"
427410
}
428411
412+
# ── Build Updater (AOT) ──
413+
# AOT compilation requires native C/C++ linker (link.exe) from Visual Studio.
414+
# Must run as a dedicated step — Start-Job child processes may lack VS toolchain.
415+
416+
- name: Build Updater (AOT)
417+
shell: pwsh
418+
run: |
419+
dotnet publish Updater/Updater.csproj -c Release -r win-x64 --no-restore
420+
if ($LASTEXITCODE -ne 0) { throw "Updater AOT build failed" }
421+
429422
# ── Publish backend ──
430423

431424
- name: Publish win-x64

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ cd XUnityToolkit-Vue && npx vue-tsc --noEmit
168168
- **gitignore:** `docs/` is gitignored; use `git add -f` when committing spec/plan documents
169169
- **gitignore negation:** `bundled/` (directory pattern) blocks child negations; use `bundled/*` (wildcard) to allow `!bundled/fonts/`
170170
- **CI/CD:** GitHub Actions; `build.yml` (reusable), `release.yml` (tag `v*`), `dep-check.yml` (daily update check → auto pre-release)
171-
- **CI parallel builds:** `build.yml` uses PowerShell `Start-Job` for intra-step parallelism — npm ci runs in background during asset download; frontend/Updater/TranslatorEndpoint build in parallel; main ZIP created in background during component ZIP creation
171+
- **CI parallel builds:** `build.yml` uses PowerShell `Start-Job` for intra-step parallelism — npm ci runs in background during asset download; frontend/TranslatorEndpoint build in parallel (Updater AOT runs as separate step — AOT needs native toolchain unreliable inside `Start-Job`); main ZIP created in background during component ZIP creation
172172
- **CI NuGet cache:** `actions/cache@v4` on `~/.nuget/packages` keyed by `hashFiles('**/*.csproj')`; explicit `dotnet restore` before parallel builds, then `--no-restore` on all subsequent dotnet commands
173173
- **CI component ZIPs:** Use `ZipFileExtensions.CreateEntryFromFile` with path prefix directly — do NOT create temp wrapper directories with `Copy-Item` (wastes I/O on large bundled assets)
174174
- **CI version tracking:** `.github/deps.json` stores last-known versions; `dep-check.yml` compares upstream

0 commit comments

Comments
 (0)