traymon/build/build.ps1
Zhang Pu f479f4edf2 init: TrayMon v1.0.0 首次发布
Windows 托盘 CPU / GPU 实时监控小工具
- 托盘图标直显 C/G 占用率,悬停显示一位小数
- 右键一键切换开机自启(当前用户 Run 键,免管理员)
- NVIDIA GPU 走 nvidia-smi,非 N 卡显示 0%
- 单文件免安装 exe(PyInstaller onefile windowed)
MIT License
2026-11-02 11:47:20 +08:00

34 lines
1.4 KiB
PowerShell
Raw Permalink 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.

# TrayMon 一键打包脚本(Windows 上执行)
# 用法:PowerShell 里执行 .\build\build.ps1
# 产物:..\release\TrayMon.exe(单文件,无控制台窗口)
$ErrorActionPreference = "Stop"
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$root = Split-Path -Parent $here
Set-Location $root
Write-Host "== 检查 Python ==" -ForegroundColor Cyan
python --version
Write-Host "== 安装依赖 ==" -ForegroundColor Cyan
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pyinstaller
Write-Host "== 清理旧的打包目录 ==" -ForegroundColor Cyan
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue build\TrayMon
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue dist
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue release
Write-Host "== 打包(单文件 / 无控制台)==" -ForegroundColor Cyan
python -m PyInstaller --onefile --windowed --name TrayMon `
--clean --noconfirm system_monitor.py
Write-Host "== 收集产物 ==" -ForegroundColor Cyan
New-Item -ItemType Directory -Force -Path release | Out-Null
Copy-Item -Force dist\TrayMon.exe release\TrayMon.exe
$size = [math]::Round((Get-Item release\TrayMon.exe).Length / 1MB, 1)
Write-Host ""
Write-Host "完成:$root\release\TrayMon.exe ($size MB)" -ForegroundColor Green
Write-Host "(release/ 已在 .gitignore 中,不会进 Git 仓库)"