fix: Disable code signing to avoid Windows symlink errors

- Add signAndEditExecutable: false to skip code signing on Windows
- Clear electron-builder winCodeSign cache before build
- Add helpful error messages for symlink permission issues

The winCodeSign package contains macOS symlinks that fail to extract
on Windows without admin privileges or Developer Mode enabled.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-16 20:48:16 +08:00
parent c19b4e8292
commit 92e203422b
3 changed files with 23 additions and 1 deletions

View File

@@ -45,7 +45,8 @@
"arch": ["x64"] "arch": ["x64"]
} }
], ],
"icon": "assets/icon.ico" "icon": "assets/icon.ico",
"signAndEditExecutable": false
}, },
"mac": { "mac": {
"target": [ "target": [

View File

@@ -239,6 +239,13 @@ function Build-Electron {
Write-Warn "已建立 .env請確認設定" Write-Warn "已建立 .env請確認設定"
} }
# 清理可能損壞的 electron-builder 快取(解決 symlink 問題)
$ebCache = Join-Path $env:LOCALAPPDATA "electron-builder\Cache\winCodeSign"
if (Test-Path $ebCache) {
Write-Host " 清理 electron-builder 快取..." -ForegroundColor Gray
Remove-Item -Recurse -Force $ebCache -ErrorAction SilentlyContinue
}
Write-Host " 執行 electron-builder..." -ForegroundColor Gray Write-Host " 執行 electron-builder..." -ForegroundColor Gray
# 直接執行 node_modules 中的 electron-builder # 直接執行 node_modules 中的 electron-builder
@@ -246,6 +253,9 @@ function Build-Electron {
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
Write-Err "electron-builder 執行失敗" Write-Err "electron-builder 執行失敗"
Write-Warn "如果出現 symlink 錯誤,請嘗試以下方案:"
Write-Warn " 1. 以系統管理員身分執行此腳本"
Write-Warn " 2. 或啟用 Windows 開發人員模式(設定 > 更新與安全性 > 開發人員專用)"
exit 1 exit 1
} }

View File

@@ -206,6 +206,14 @@ echo %BLUE%[STEP]%NC% 打包 Electron 應用...
cd /d "%CLIENT_DIR%" cd /d "%CLIENT_DIR%"
echo %BLUE%[INFO]%NC% 目標平台: Windows (Portable) echo %BLUE%[INFO]%NC% 目標平台: Windows (Portable)
REM 清理可能損壞的 electron-builder 快取(解決 symlink 問題)
set "EB_CACHE=%LOCALAPPDATA%\electron-builder\Cache\winCodeSign"
if exist "%EB_CACHE%" (
echo %BLUE%[INFO]%NC% 清理 electron-builder 快取...
rmdir /s /q "%EB_CACHE%" 2>nul
)
echo %BLUE%[INFO]%NC% 執行 electron-builder... echo %BLUE%[INFO]%NC% 執行 electron-builder...
REM 使用 npm run build 或直接執行 node_modules 中的 electron-builder REM 使用 npm run build 或直接執行 node_modules 中的 electron-builder
@@ -217,6 +225,9 @@ if exist "node_modules\.bin\electron-builder.cmd" (
if errorlevel 1 ( if errorlevel 1 (
echo %RED%[ERROR]%NC% electron-builder 執行失敗 echo %RED%[ERROR]%NC% electron-builder 執行失敗
echo %YELLOW%[WARN]%NC% 如果出現 symlink 錯誤,請嘗試以下方案:
echo %YELLOW%[WARN]%NC% 1. 以系統管理員身分執行此腳本
echo %YELLOW%[WARN]%NC% 2. 或啟用 Windows 開發人員模式(設定 ^> 更新與安全性 ^> 開發人員專用)
exit /b 1 exit /b 1
) )