Files
ngzz-mc/scripts/make_installer.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

54 lines
2.6 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.
# 年糕历险记 —— 便携安装包构建脚本(中文安装,构建与发布.md §8 交付方案)
# 用法:pwsh -File scripts/make_installer.ps1 [-Version 0.1.0]
# 产物:dist/年糕历险记-Setup-v<版本>.zip(解压后运行 安装.bat,全中文交互)
param([string]$Version = "0.1.0")
$ErrorActionPreference = "Stop"
$root = Split-Path $PSScriptRoot -Parent
$dist = Join-Path $root "dist"
$stage = Join-Path $dist "年糕历险记-Setup-v$Version"
# 1) 构建(复用 build.ps1 逻辑:定位 zig/gcc)
& (Join-Path $PSScriptRoot "build.ps1")
if ($LASTEXITCODE -ne 0) { throw "构建失败" }
# 2) 组装安装目录
if (Test-Path $stage) { Remove-Item $stage -Recurse -Force }
New-Item -ItemType Directory -Force -Path $stage | Out-Null
Copy-Item (Join-Path $root "bin\mc-client.exe") $stage
Copy-Item (Join-Path $root "bin\mc-server.exe") $stage
New-Item -ItemType Directory -Force -Path (Join-Path $stage "config") | Out-Null
Copy-Item (Join-Path $root "config\client.yaml") (Join-Path $stage "config")
Copy-Item (Join-Path $root "config\server.yaml") (Join-Path $stage "config")
New-Item -ItemType Directory -Force -Path (Join-Path $stage "mods") | Out-Null
Copy-Item (Join-Path $root "mods\README.md") (Join-Path $stage "mods")
# 游戏数据(方块/物品/配方注册表)
Copy-Item (Join-Path $root "assets") (Join-Path $stage "assets") -Recurse
# 默认素材包
Copy-Item (Join-Path $root "resourcepacks") (Join-Path $stage "resourcepacks") -Recurse
# 安装脚本(GBK 编码保证 cmd 中文显示)
Copy-Item (Join-Path $PSScriptRoot "installer\安装.bat") (Join-Path $stage "安装.bat")
# 游戏说明(中文)
[System.IO.File]::WriteAllText((Join-Path $stage "README.txt"), @"
年糕历险记 v$Version
====================
安装:双击 安装.bat(选择安装目录,可选创建桌面快捷方式,默认创建;
安装完成后可选立即运行游戏,默认运行)。
卸载:删除安装目录即可(存档保存在安装目录 worlds/ 下)。
素材包/光影包:解压到 mods/ 目录(原生 Minecraft 资源包格式直接支持)。
未安装光影包时使用系统默认光影。
$(Get-Date -Format "yyyy-MM-dd")
"@, (New-Object System.Text.UTF8Encoding($false)))
# 3) 打包 zip(中文文件名)
$zipPath = Join-Path $dist "年糕历险记-Setup-v$Version.zip"
if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
Compress-Archive -Path (Join-Path $stage "*") -DestinationPath $zipPath
Remove-Item $stage -Recurse -Force
$sizeMB = [math]::Round((Get-Item $zipPath).Length / 1MB, 1)
Write-Host "== 安装包就绪:$zipPath($sizeMB MB)=="