From 92e203422b064c6ea5dfe5fbadb47f05aae4152c Mon Sep 17 00:00:00 2001 From: egg Date: Tue, 16 Dec 2025 20:48:16 +0800 Subject: [PATCH] fix: Disable code signing to avoid Windows symlink errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- client/package.json | 3 ++- scripts/build-all.ps1 | 10 ++++++++++ scripts/build-client.bat | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/client/package.json b/client/package.json index 354819c..1139242 100644 --- a/client/package.json +++ b/client/package.json @@ -45,7 +45,8 @@ "arch": ["x64"] } ], - "icon": "assets/icon.ico" + "icon": "assets/icon.ico", + "signAndEditExecutable": false }, "mac": { "target": [ diff --git a/scripts/build-all.ps1 b/scripts/build-all.ps1 index 2b7ea49..ef0ef04 100644 --- a/scripts/build-all.ps1 +++ b/scripts/build-all.ps1 @@ -239,6 +239,13 @@ function Build-Electron { 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 # 直接執行 node_modules 中的 electron-builder @@ -246,6 +253,9 @@ function Build-Electron { if ($LASTEXITCODE -ne 0) { Write-Err "electron-builder 執行失敗" + Write-Warn "如果出現 symlink 錯誤,請嘗試以下方案:" + Write-Warn " 1. 以系統管理員身分執行此腳本" + Write-Warn " 2. 或啟用 Windows 開發人員模式(設定 > 更新與安全性 > 開發人員專用)" exit 1 } diff --git a/scripts/build-client.bat b/scripts/build-client.bat index 7766386..6f3e068 100644 --- a/scripts/build-client.bat +++ b/scripts/build-client.bat @@ -206,6 +206,14 @@ echo %BLUE%[STEP]%NC% 打包 Electron 應用... cd /d "%CLIENT_DIR%" 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... REM 使用 npm run build 或直接執行 node_modules 中的 electron-builder @@ -217,6 +225,9 @@ if exist "node_modules\.bin\electron-builder.cmd" ( if errorlevel 1 ( 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 )