修复打包脚本

This commit is contained in:
zhengxuan.zhang
2026-08-06 11:34:01 +08:00
parent 8855169e5f
commit e5c4ce4d98
+22 -5
View File
@@ -1,4 +1,4 @@
param(
param(
# 不传时自动从 XplorePlane.csproj 的 <Version> 读取,传入则覆盖工程配置(用于临时测试版本号)
[string]$Version,
@@ -61,8 +61,16 @@ Write-Host "========================================================" -Foregroun
Write-Host ""
# Step 1: Clean
Write-Host "[1/5] Cleaning publish directory..." -ForegroundColor Yellow
if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force }
# 仅在即将重新构建时清理 publish 目录:-SkipBuild 场景下需要复用已有的发布产物
# (例如仅因 vpk 打包阶段文件占用失败而重试),此前无条件清理会导致 -SkipBuild
# 传入后必然因目录被清空而报错,参数形同虚设。
if (-not $SkipBuild) {
Write-Host "[1/5] Cleaning publish directory..." -ForegroundColor Yellow
if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force }
} else {
Write-Host "[1/5] Skipped clean (-SkipBuild, reusing existing publish directory)" -ForegroundColor DarkGray
}
# Step 2: Build and Publish
if (-not $SkipBuild) {
@@ -152,6 +160,14 @@ if (-not $vpkCmd) {
Write-Host "FAILED: vpk install failed" -ForegroundColor Red
exit 1
}
# 当前 PowerShell 进程的 PATH 可能尚未包含全局工具目录,安装后重新解析一次。
$vpkCmd = Get-Command vpk -ErrorAction SilentlyContinue
}
$vpkPath = if ($vpkCmd) { $vpkCmd.Source } else { Join-Path $HOME ".dotnet\tools\vpk.exe" }
if (-not (Test-Path -LiteralPath $vpkPath)) {
Write-Host "FAILED: vpk executable not found: $vpkPath" -ForegroundColor Red
exit 1
}
if (-not $NoMsi) {
@@ -165,7 +181,8 @@ $vpkArgs = @(
"--packAuthors", $PackAuthors,
"--packVersion", $Version,
"--packDir", $PublishDir,
"--mainExe", $MainExe
"--mainExe", $MainExe,
"--outputDir", $ReleasesDir
)
if (-not $NoMsi) {
@@ -176,7 +193,7 @@ if (-not $NoMsi) {
$vpkArgs += $InstallLocation
}
& vpk @vpkArgs
& $vpkPath @vpkArgs
if ($LASTEXITCODE -ne 0) {
Write-Host "FAILED: vpk pack failed!" -ForegroundColor Red
exit 1