fix(windows): use NSIS installer instead of WiX MSI on CI

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-28 08:47:33 +08:00
parent 673c23e87c
commit aef449e0e4
3 changed files with 17 additions and 4 deletions

View File

@@ -42,10 +42,16 @@ if (!fs.existsSync(indexPath)) {
process.exit(1);
}
function toSafeBinaryName(name, fallback) {
const ascii = name.replace(/[^a-zA-Z0-9_-]+/g, "");
return (ascii || fallback).slice(0, 64);
}
function patchTauriConfig(filePath) {
const conf = JSON.parse(fs.readFileSync(filePath, "utf8"));
const safeBinaryName = toSafeBinaryName(appName, `App${jobId}`);
conf.productName = appName;
conf.mainBinaryName = appName.replace(/[^\w.-]+/g, "") || "Web2App";
conf.mainBinaryName = safeBinaryName;
conf.identifier = appIdentifier;
conf.version = "1.0.0";
if (conf.app?.windows?.[0]) {

View File

@@ -50,14 +50,21 @@ jobs:
- name: Build Windows app
working-directory: template
run: npm run tauri build
run: npm run tauri build -- --bundles nsis
- name: Collect Windows artifacts
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path artifacts/windows | Out-Null
Get-ChildItem -Path "template/src-tauri/target/release/bundle" -Recurse -Include *.exe,*.msi |
$bundleRoot = "template/src-tauri/target/release/bundle"
if (Test-Path $bundleRoot) {
Get-ChildItem -Path $bundleRoot -Recurse -Include *setup.exe,*.exe,*.msi -ErrorAction SilentlyContinue |
Copy-Item -Destination artifacts/windows -Force
}
Get-ChildItem -Path "template/src-tauri/target/release" -Filter "*.exe" -ErrorAction SilentlyContinue |
Where-Object { $_.Name -notmatch "wix|candle|light" } |
Copy-Item -Destination artifacts/windows -Force
Get-ChildItem artifacts/windows
- uses: actions/upload-artifact@v4
with:

View File

@@ -26,7 +26,7 @@
},
"bundle": {
"active": true,
"targets": "all",
"targets": ["nsis"],
"icon": [
"icons/32x32.png",
"icons/128x128.png",