Files
ngzz-mc/scripts/make_icon.ps1
NianGao Dev 9e7d4d20e2 feat(build): 程序图标使用原版素材 logo + 安装器运行/快捷方式选项
- scripts/make_icon.ps1:素材包 pack.png → go-winres 生成 icon.syso
  (嵌入 exe 图标与版本信息);窗口图标运行时 SetWindowIcon
- 安装.bat:桌面快捷方式 [Y/n](默认 Y)、安装后立即运行 [Y/n](默认 Y)
- build.ps1 在 syso 缺失时自动生成图标
2026-08-16 23:23:31 +08:00

28 lines
1.5 KiB
PowerShell
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.
# 年糕历险记 —— 程序图标生成(构建与发布.md §8exe/窗口使用原版素材 logo
# 用法pwsh -File scripts/make_icon.ps1
# 流程:素材包 pack.png → cmd/client/icon.png → go-winres 生成 cmd/client/icon.syso
# 资源目录树格式Go 链接器自动嵌入 exe资源管理器/任务栏/快捷方式显示图标)。
$ErrorActionPreference = "Stop"
$root = Split-Path $PSScriptRoot -Parent
# 1) 定位素材包 pack.png原版 logo高优先级包在前→ 复制为 icon.png
$png = $null
foreach ($dir in Get-ChildItem (Join-Path $root "resourcepacks") -Directory -ErrorAction SilentlyContinue) {
$cand = Join-Path $dir.FullName "pack.png"
if (Test-Path $cand) { $png = $cand; break }
}
if (-not $png) { throw "未找到素材包 pack.pngresourcepacks/*/pack.png" }
Copy-Item $png (Join-Path $root "cmd\client\icon.png") -Force
Write-Host "== 图标来源:$png =="
# 2) go-winres 生成 .syso多尺寸图标组 + 版本资源winres.json 引用 icon.png
$env:GOCACHE = Join-Path $root ".gocache"
Push-Location (Join-Path $root "cmd\client")
try {
go run github.com/tc-hib/go-winres@latest make --in winres.json --out icon --arch amd64 --no-suffix
if ($LASTEXITCODE -ne 0) { throw "go-winres 生成失败" }
Move-Item -Force (Join-Path (Get-Location) "icon") (Join-Path (Get-Location) "icon.syso")
} finally {
Pop-Location
}
Write-Host "== 图标资源已嵌入cmd/client/icon.syso =="