GuDingZiChan/print-agent-dotnet/build-release.ps1
WuYongJie c7a9324635 feat(打印): 新增远程标签打印与 .NET 打印助手
- 新增打印终端、配对码、打印任务相关表结构与接口\n- 增加后台打印终端/任务管理页和资产标签远程打印入口\n- 引入 .NET 8 Windows 打印助手源码及下载清单配置
2026-03-25 21:05:30 +08:00

94 lines
3.6 KiB
PowerShell

param(
[string]$Version = '0.2.0',
[string]$PublishedAt = '',
[string]$DotnetPath = '',
[string]$IsccPath = ''
)
$ErrorActionPreference = 'Stop'
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$repoRoot = Split-Path -Parent $scriptRoot
if ([string]::IsNullOrWhiteSpace($DotnetPath)) {
$DotnetPath = Join-Path $repoRoot '.dotnet8\dotnet.exe'
}
if (-not (Test-Path $DotnetPath)) {
throw "未找到 .NET 8 可执行文件:$DotnetPath"
}
if ([string]::IsNullOrWhiteSpace($IsccPath)) {
$candidatePaths = @(
'C:\Users\54972\AppData\Local\Programs\Inno Setup 6\ISCC.exe',
'C:\Program Files (x86)\Inno Setup 6\ISCC.exe',
'C:\Program Files\Inno Setup 6\ISCC.exe'
)
$IsccPath = $candidatePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
}
if (-not $IsccPath -or -not (Test-Path $IsccPath)) {
throw '未找到 Inno Setup 编译器 ISCC.exe'
}
if ([string]::IsNullOrWhiteSpace($PublishedAt)) {
$PublishedAt = (Get-Date).ToString('yyyy-MM-ddTHH:mm:sszzz')
}
$publishDir = Join-Path $scriptRoot 'dist\publish\win-x64'
$installerDir = Join-Path $scriptRoot 'dist\installer'
$releaseDir = Join-Path $repoRoot "downloads\print-agent\releases\$Version"
$latestDir = Join-Path $repoRoot 'downloads\print-agent\latest'
New-Item -ItemType Directory -Force -Path $publishDir, $installerDir, $releaseDir, $latestDir | Out-Null
& $DotnetPath publish `
(Join-Path $scriptRoot 'FixedAssetPrintAgent\FixedAssetPrintAgent.csproj') `
-c Release `
-r win-x64 `
--self-contained true `
-p:PublishSingleFile=true `
-p:EnableCompressionInSingleFile=true `
-o $publishDir
& $IsccPath (Join-Path $scriptRoot 'installer\FixedAssetPrintAgent.iss')
$installerSource = Join-Path $installerDir "print-agent-setup-$Version.exe"
if (-not (Test-Path $installerSource)) {
throw "未生成安装包:$installerSource"
}
$versionedInstaller = Join-Path $releaseDir "print-agent-setup-$Version.exe"
$latestInstaller = Join-Path $latestDir 'print-agent-setup.exe'
Copy-Item -Force $installerSource $versionedInstaller
Copy-Item -Force $installerSource $latestInstaller
$releaseManifest = [ordered]@{
version = $Version
published_at = $PublishedAt
filename = "print-agent-setup-$Version.exe"
notes = '打印助手 v0.2.0,已切换为 .NET 8 原生 Windows 托盘版,带正式安装器、控制面板卸载入口、配对接入、心跳、任务轮询、驱动帮助、测试打印与资产标签静默打印。'
source_type = 'server_release'
relative_path = "downloads/print-agent/releases/$Version/print-agent-setup-$Version.exe"
relativePath = "downloads/print-agent/releases/$Version/print-agent-setup-$Version.exe"
} | ConvertTo-Json -Depth 5
$latestManifest = [ordered]@{
version = $Version
published_at = $PublishedAt
filename = 'print-agent-setup.exe'
notes = '打印助手最新稳定版,当前为 .NET 8 原生 Windows 托盘安装包,支持正式安装、卸载、配对接入、心跳、任务轮询、驱动帮助、测试打印与资产标签静默打印。'
source_type = 'server_release'
relative_path = 'downloads/print-agent/latest/print-agent-setup.exe'
relativePath = 'downloads/print-agent/latest/print-agent-setup.exe'
} | ConvertTo-Json -Depth 5
Set-Content -Path (Join-Path $releaseDir 'manifest.json') -Value $releaseManifest -Encoding UTF8
Set-Content -Path (Join-Path $latestDir 'manifest.json') -Value $latestManifest -Encoding UTF8
$installerSizeMB = [Math]::Round((Get-Item $installerSource).Length / 1MB, 2)
Write-Host "安装包已生成:$installerSource ($installerSizeMB MB)"
Write-Host "已同步到:$releaseDir"
Write-Host "已更新 latest 清单和下载包。"