From 9ebaf0d177d03902ece3a9a24e0d98d478f0b6b3 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 29 Oct 2026 14:42:56 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E6=89=93=E5=8C=85=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20UTF-8=20BOM=EF=BC=8C=E5=85=BC=E5=AE=B9=20W?= =?UTF-8?q?indows=20PowerShell=205.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/build_exe.ps1 | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/tools/build_exe.ps1 b/tools/build_exe.ps1 index 0629252..ac861b7 100644 --- a/tools/build_exe.ps1 +++ b/tools/build_exe.ps1 @@ -1,9 +1,9 @@ -# 构建单文件 exe(Windows) +# Build a single-file Windows exe. # # powershell -ExecutionPolicy Bypass -File tools\build_exe.ps1 # -# 产物: dist\U盘备份工具.exe -# 依赖: python -m pip install pyinstaller +# Output: dist\U盘备份工具.exe +# Requires: python -m pip install pyinstaller param( [string]$Name = "U盘备份工具" @@ -14,26 +14,20 @@ $root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path) $work = Join-Path $root "build" $dist = Join-Path $root "dist" -Write-Host "构建 $Name ..." +Write-Host "Building $Name ..." Push-Location $root try { - python -m PyInstaller --noconfirm --clean --onefile --windowed ` - --icon (Join-Path $root "icon.ico") ` - --name $Name ` - --version-file (Join-Path $PSScriptRoot "version_info.txt") ` - --distpath $dist ` - --workpath $work ` - --specpath $work ` - (Join-Path $root "usb_backup.py") - if ($LASTEXITCODE -ne 0) { throw "PyInstaller 失败,退出码 $LASTEXITCODE" } + python -m PyInstaller --noconfirm --clean --onefile --windowed --icon (Join-Path $root "icon.ico") --name $Name --version-file (Join-Path $PSScriptRoot "version_info.txt") --distpath $dist --workpath $work --specpath $work (Join-Path $root "usb_backup.py") + if ($LASTEXITCODE -ne 0) { throw "PyInstaller failed with exit code $LASTEXITCODE" } } finally { Pop-Location } $exe = Join-Path $dist "$Name.exe" -if (-not (Test-Path $exe)) { throw "未生成 $exe" } +if (-not (Test-Path $exe)) { throw "missing $exe" } $size = [math]::Round((Get-Item $exe).Length / 1MB, 2) $hash = (Get-FileHash $exe -Algorithm SHA256).Hash + Write-Host "" -Write-Host "完成: $exe ($size MB)" +Write-Host "OK: $exe ($size MB)" Write-Host "SHA256: $hash"