# 年糕历险记 —— 程序图标生成(构建与发布.md §8:exe/窗口使用原版素材 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.png(resourcepacks/*/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 =="