From 58c229dacecd2ebdb67364b44cb8bb26efc5848a Mon Sep 17 00:00:00 2001 From: weikeyi Date: Mon, 11 May 2026 16:07:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(windows-ci):=20WiX=20=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=8C=89=20WixTools*=20=E9=80=9A=E9=85=8D=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=20Tauri=20=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=90=8E=E8=B7=AF=E5=BE=84=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows MSI Repair 之前硬编码 `C:\Users\22933\AppData\Local\tauri\WixTools314\light.exe`,Tauri 升级到新 WiX 版本(如 WixTools315)后路径不存在,Repair 步骤直接挂。 改为 WixTools* glob,按数字后缀降序回退到名称降序,取最新可用版本。同步更新 windows-package-msvc.ps1::Find-WixTool 和 release-tauri.yml 的 Repair 步骤;保留 -sice:ICE80、NSIS/MSI 两轮 build、bash shell 等 Windows CI 红线不变。 补 4 条 windows-package-msvc.test.mjs 防回归断言:禁止 WixTools314 出现在脚本/workflow,要求两边都按 WixTools* glob 查找。 Refs: #298 --- .github/workflows/release-tauri.yml | 6 ++++-- openless-all/app/scripts/windows-package-msvc.ps1 | 15 +++++++++++---- .../app/scripts/windows-package-msvc.test.mjs | 13 ++++++++----- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-tauri.yml b/.github/workflows/release-tauri.yml index 9ae2c441..8192bc96 100644 --- a/.github/workflows/release-tauri.yml +++ b/.github/workflows/release-tauri.yml @@ -300,8 +300,10 @@ jobs: throw "Required WiX object missing: $p — tauri build aborted before candle ran. Check the Build (Windows) step log." } } - $light = (Get-ChildItem "$env:LOCALAPPDATA\tauri\WixTools314\light.exe" -ErrorAction SilentlyContinue | Select-Object -First 1).FullName - if (-not $light) { throw "WiX light.exe not found in $env:LOCALAPPDATA\tauri\WixTools314" } + $light = Get-ChildItem "$env:LOCALAPPDATA\tauri\WixTools*\light.exe" -ErrorAction SilentlyContinue | + Sort-Object FullName | + Select-Object -Last 1 -ExpandProperty FullName + if (-not $light) { throw "WiX light.exe not found under $env:LOCALAPPDATA\tauri\WixTools*" } $version = (Get-Content src-tauri\tauri.conf.json -Raw | ConvertFrom-Json).version $bundleDir = Join-Path $appRoot 'src-tauri\target\release\bundle\msi' New-Item -ItemType Directory -Force -Path $bundleDir | Out-Null diff --git a/openless-all/app/scripts/windows-package-msvc.ps1 b/openless-all/app/scripts/windows-package-msvc.ps1 index baff9663..4eecf92e 100644 --- a/openless-all/app/scripts/windows-package-msvc.ps1 +++ b/openless-all/app/scripts/windows-package-msvc.ps1 @@ -93,9 +93,16 @@ function Find-VsDevCmd { } function Find-WixTool($Name) { - $tauriWixTool = Join-Path $env:LOCALAPPDATA "tauri\WixTools314\$Name" - if (Test-Path $tauriWixTool) { - return (Resolve-Path $tauriWixTool).Path + $tauriWixRoot = Join-Path $env:LOCALAPPDATA "tauri" + if (Test-Path $tauriWixRoot) { + $tauriWixTools = Get-ChildItem -LiteralPath $tauriWixRoot -Directory -Filter "WixTools*" -ErrorAction SilentlyContinue | + Sort-Object @{ Expression = { if ($_.Name -match '^WixTools(\d+)$') { [int]$Matches[1] } else { -1 } }; Descending = $true }, @{ Expression = "Name"; Descending = $true } + foreach ($toolDir in $tauriWixTools) { + $tauriWixTool = Join-Path $toolDir.FullName $Name + if (Test-Path $tauriWixTool) { + return (Resolve-Path $tauriWixTool).Path + } + } } $cmd = Get-Command $Name -ErrorAction SilentlyContinue @@ -103,7 +110,7 @@ function Find-WixTool($Name) { return $cmd.Source } - throw "$Name not found. Run the Tauri MSI build once so the WiX tools are installed." + throw "$Name not found. Run the Tauri MSI build once so a WiX tools directory is installed under $tauriWixRoot." } function Get-PackageVersion { diff --git a/openless-all/app/scripts/windows-package-msvc.test.mjs b/openless-all/app/scripts/windows-package-msvc.test.mjs index d5a17eed..ce5aa4ec 100644 --- a/openless-all/app/scripts/windows-package-msvc.test.mjs +++ b/openless-all/app/scripts/windows-package-msvc.test.mjs @@ -65,6 +65,10 @@ for (const fragment of requiredFragments) { assert.match(script, /\[switch\]\$SkipRustInstall/, "script should support opting out of Rust installation"); assert.match(script, /\[switch\]\$SkipNpmCi/, "script should support reusing existing node_modules"); assert.match(script, /\[switch\]\$CleanArtifacts/, "script should support cleaning the output directory"); +assert.doesNotMatch(script, /WixTools314/, "MSVC packaging must not hard-code a single Tauri WiX tools version"); +assert.doesNotMatch(ciWorkflow, /WixTools314/, "CI MSI repair must not hard-code a single Tauri WiX tools version"); +assert.match(script, /-Filter "WixTools\*"/, "MSVC packaging should discover Tauri WiX tools by WixTools* glob"); +assert.match(ciWorkflow, /WixTools\*\\light\.exe/, "CI MSI repair should discover Tauri WiX tools by WixTools* glob"); assert.match(imeBuild, /\[string\]\$OutputDirectory/, "IME build should support a package-specific output directory"); assert.match(imeBuild, /\[string\]\$IntermediateDirectory/, "IME build should support a package-specific intermediate directory"); @@ -120,11 +124,10 @@ assert.match(wixFragment, /UnregisterOpenLessImeX86/, "MSI should unregister x86 assert.match(nsisHook, /NSIS_HOOK_PREINSTALL/, "NSIS should copy IME DLLs before install completes"); assert.match(nsisHook, /NSIS_HOOK_POSTINSTALL/, "NSIS should register IME DLLs after files are installed"); assert.match(nsisHook, /NSIS_HOOK_PREUNINSTALL/, "NSIS should unregister IME DLLs before uninstall removes them"); -assert.match(nsisHook, /\$%OPENLESS_IME_DLL_X64%/, "NSIS should consume the CI-built x64 IME DLL"); -assert.match(nsisHook, /\$%OPENLESS_IME_DLL_X86%/, "NSIS should consume the CI-built x86 IME DLL"); -assert.match(nsisHook, /SetOutPath "\$INSTDIR\\windows-ime\\x64"/, "NSIS should install the x64 IME DLL beside the app"); -assert.match(nsisHook, /SetOutPath "\$INSTDIR\\windows-ime\\x86"/, "NSIS should install the x86 IME DLL beside the app"); -assert.match(nsisHook, /File \/oname=OpenLessIme\.dll/, "NSIS should embed OpenLessIme.dll in the installer"); +assert.match(nsisHook, /OPENLESS_IME_STAGE_AND_REPLACE "x64" "OPENLESS_IME_DLL_X64"/, "NSIS should consume the CI-built x64 IME DLL"); +assert.match(nsisHook, /OPENLESS_IME_STAGE_AND_REPLACE "x86" "OPENLESS_IME_DLL_X86"/, "NSIS should consume the CI-built x86 IME DLL"); +assert.match(nsisHook, /SetOutPath "\$INSTDIR\\windows-ime\\\$\{PLATFORM_DIR\}"/, "NSIS should install the IME DLL beside the app by platform"); +assert.match(nsisHook, /File \/oname=OpenLessIme\.dll\.new "\$%\$\{ENV_VAR\}%"/, "NSIS should embed OpenLessIme.dll in the installer"); assert.match(nsisHook, /Sysnative\\regsvr32\.exe/, "NSIS should use 64-bit regsvr32 for the x64 IME"); assert.match(nsisHook, /SysWOW64\\regsvr32\.exe/, "NSIS should use 32-bit regsvr32 for the x86 IME"); assert.match(nsisHook, /System32\\regsvr32\.exe[\s\S]*windows-ime\\x86\\OpenLessIme\.dll/, "NSIS should use System32 regsvr32 for the x86 IME on 32-bit Windows");