Files
zerorigin-toolbox/build.bat
T
zerorigin2019 814012ec52 fix: 构建环境 NODE_ENV=production 导致 npm 跳过 devDependencies
- build.bat 显式 set NODE_ENV=development + NPM_CONFIG_PRODUCTION=false
  (外部环境注入 NODE_ENV=production 时 vite/vue-tsc 静默不装,
  wails3 build 报 'vue-tsc' is not recognized)
- 清理 frontend/package.json 残留的 'test' 脏字符(JSON 解析失败源头)
- 重新生成 package-lock.json
2026-08-05 01:12:24 +08:00

58 lines
2.2 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
chcp 65001 >nul
cd /d "%~dp0"
rem 防止外部环境(如 NODE_ENV=production)导致 npm 跳过 devDependencies
rem (vite/vue-tsc 不装 → wails3 build 报 'vue-tsc' is not recognized)
set NODE_ENV=development
set NPM_CONFIG_PRODUCTION=false
echo [build] 终止旧进程...
taskkill /f /im zerorigin.exe >nul 2>&1
taskkill /f /im ZerOriginTool-Settings.exe >nul 2>&1
echo [build] 生成主进程图标资源 (rsrc.syso)...
for /f "tokens=*" %%i in ('go env GOPATH') do set "GOPATH=%%i"
"%GOPATH%\bin\rsrc.exe" -ico assets\logo.ico -manifest app.manifest -o cmd\zerorigin\rsrc.syso
if %errorlevel% neq 0 (echo [build] rsrc 失败! && exit /b 1)
echo [build] 编译主进程...
go build -ldflags="-s -w -H windowsgui -X zerorigin/internal/version.Version=0.1.0" -o bin\ZerOriginTool.exe .\cmd\zerorigin
if %errorlevel% neq 0 (del cmd\zerorigin\rsrc.syso 2>nul && echo [build] 编译失败! && exit /b 1)
del cmd\zerorigin\rsrc.syso 2>nul
echo [build] 构建设置进程(前端 + Wails)...
set PATH=%GOPATH%\bin;%PATH%
pushd cmd\settings
call wails3 build
popd
if not exist cmd\settings\bin\settings.exe (echo [build] 设置进程构建失败! && exit /b 1)
copy /y cmd\settings\bin\settings.exe bin\ZerOriginTool-Settings.exe >nul
echo [build] 编译监督进程 (watchdog)...
go build -ldflags="-s -w -H windowsgui" -o bin\watchdog.exe .\cmd\watchdog
if %errorlevel% neq 0 (echo [build] watchdog 编译失败! && exit /b 1)
echo [build] 生成便携版...
if not exist portable mkdir portable
copy /y bin\ZerOriginTool.exe portable\ZerOriginTool.exe >nul
copy /y bin\ZerOriginTool-Settings.exe portable\ZerOriginTool-Settings.exe >nul
copy /y bin\watchdog.exe portable\watchdog.exe >nul
echo [build] 编译安装包 (NSIS)...
if exist "C:\Program Files (x86)\NSIS\makensis.exe" (
pushd deploy
"C:\Program Files (x86)\NSIS\makensis.exe" -INPUTCHARSET UTF8 installer.nsi
popd
if exist deploy\ZerOriginTool_Setup.exe (
copy /y deploy\ZerOriginTool_Setup.exe bin\ZerOriginTool_Setup.exe >nul
del deploy\ZerOriginTool_Setup.exe
)
) else (
echo [build] 未找到 NSIS,跳过安装包。
)
echo [build] 完成:
dir /b bin\*.exe
echo 便携版:portable\(含两个 exe 与说明)