- tools/build_exe.ps1:一条命令出 dist\\U盘备份工具.exe(onefile/windowed/图标/版本信息),并打印 SHA-256 - tools/version_info.txt:2.1.0.0 版本资源 - get_volume_info 统一换算到卷根再查询:传子目录/文件也能拿到文件系统,修复 FAT32 4GB 上限与脏卷提示依赖 vol['fs'] 失效的问题 - 新增 2 项体积/卷信息测试(共 32 项)
40 lines
1.2 KiB
PowerShell
40 lines
1.2 KiB
PowerShell
# 构建单文件 exe(Windows)
|
||
#
|
||
# powershell -ExecutionPolicy Bypass -File tools\build_exe.ps1
|
||
#
|
||
# 产物: dist\U盘备份工具.exe
|
||
# 依赖: python -m pip install pyinstaller
|
||
|
||
param(
|
||
[string]$Name = "U盘备份工具"
|
||
)
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||
$work = Join-Path $root "build"
|
||
$dist = Join-Path $root "dist"
|
||
|
||
Write-Host "构建 $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" }
|
||
} finally {
|
||
Pop-Location
|
||
}
|
||
|
||
$exe = Join-Path $dist "$Name.exe"
|
||
if (-not (Test-Path $exe)) { throw "未生成 $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 "SHA256: $hash"
|