From aef449e0e4fa898e43fd458eb639fec034e1ff81 Mon Sep 17 00:00:00 2001 From: shumengya Date: Thu, 28 May 2026 08:47:33 +0800 Subject: [PATCH] fix(windows): use NSIS installer instead of WiX MSI on CI Co-authored-by: Cursor --- .github/scripts/prepare-template.mjs | 8 +++++++- .github/workflows/build-app.yml | 11 +++++++++-- template/src-tauri/tauri.conf.json | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/scripts/prepare-template.mjs b/.github/scripts/prepare-template.mjs index 3efd76a..0e18ba0 100644 --- a/.github/scripts/prepare-template.mjs +++ b/.github/scripts/prepare-template.mjs @@ -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]) { diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml index ad40ca3..88c63b4 100644 --- a/.github/workflows/build-app.yml +++ b/.github/workflows/build-app.yml @@ -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: diff --git a/template/src-tauri/tauri.conf.json b/template/src-tauri/tauri.conf.json index c830932..dabe568 100644 --- a/template/src-tauri/tauri.conf.json +++ b/template/src-tauri/tauri.conf.json @@ -26,7 +26,7 @@ }, "bundle": { "active": true, - "targets": "all", + "targets": ["nsis"], "icon": [ "icons/32x32.png", "icons/128x128.png",