版本号体系落地:AssemblyInfo 固定三段式 1.0.3 为唯一事实源(禁用 1.0.* 自动号);关于软件运行时读程序集版本;setup.iss 带版本号并纳入 git;新增 tools\递增版本号.ps1 一键递增三处同步(已自测往返);技能写入版本号铁律(每次发版必须递增)
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
# ============================================================
|
||||
# 递增版本号.ps1 —— 版本号一键递增并三处同步
|
||||
# ============================================================
|
||||
# 唯一事实源: 成套报价软件\Properties\AssemblyInfo.cs 的 AssemblyVersion
|
||||
# 同步点: ① AssemblyInfo.cs (AssemblyVersion + AssemblyFileVersion)
|
||||
# ② release\成套报价软件\setup.iss (AppVersion + OutputBaseFilename)
|
||||
# 关于软件窗口自动读程序集版本,无需同步。
|
||||
# 用法:
|
||||
# powershell -File tools\递增版本号.ps1 # 修订号 +1 (1.0.3 → 1.0.4)
|
||||
# powershell -File tools\递增版本号.ps1 1.1.0 # 直接指定版本
|
||||
# 发版流程: 本脚本 → 编译 → make_package → ISCC → 更新包 → git 提交推送
|
||||
# → Gitea Release(tag 与版本号一致,如 v1.0.4)
|
||||
# ============================================================
|
||||
param([string]$SetVersion = "")
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
$asm = Join-Path $root '成套报价软件\Properties\AssemblyInfo.cs'
|
||||
$iss = Join-Path $root 'release\成套报价软件\setup.iss'
|
||||
|
||||
# --- 读当前版本 ---
|
||||
$asmText = [System.IO.File]::ReadAllText($asm)
|
||||
if ($asmText -notmatch 'AssemblyVersion\("(\d+)\.(\d+)\.(\d+)') {
|
||||
Write-Host "[FAIL] AssemblyInfo.cs 里没找到三段式 AssemblyVersion" -ForegroundColor Red; exit 1
|
||||
}
|
||||
$cur = "{0}.{1}.{2}" -f $Matches[1], $Matches[2], $Matches[3]
|
||||
|
||||
# --- 算新版本 ---
|
||||
if ($SetVersion -eq "") {
|
||||
$new = "{0}.{1}.{2}" -f $Matches[1], $Matches[2], ([int]$Matches[3] + 1)
|
||||
} else {
|
||||
if ($SetVersion -notmatch '^\d+\.\d+\.\d+$') {
|
||||
Write-Host "[FAIL] 版本号格式须为 主.次.修订,如 1.1.0" -ForegroundColor Red; exit 1
|
||||
}
|
||||
$new = $SetVersion
|
||||
}
|
||||
|
||||
# --- ① AssemblyInfo: AssemblyVersion + AssemblyFileVersion ---
|
||||
$asmText = $asmText -replace 'AssemblyVersion\("\d+\.\d+\.\d+[\.\d]*"\)', "AssemblyVersion(`"$new.0`")"
|
||||
$asmText = $asmText -replace 'AssemblyFileVersion\("\d+\.\d+\.\d+[\.\d]*"\)', "AssemblyFileVersion(`"$new.0`")"
|
||||
[System.IO.File]::WriteAllText($asm, $asmText, (New-Object System.Text.UTF8Encoding $true))
|
||||
Write-Host "[OK] AssemblyInfo.cs: $cur -> $new"
|
||||
|
||||
# --- ② setup.iss: AppVersion + OutputBaseFilename ---
|
||||
$issText = [System.IO.File]::ReadAllText($iss)
|
||||
$issText = $issText -replace 'AppVersion=\d+\.\d+\.\d+', "AppVersion=$new"
|
||||
$issText = $issText -replace 'OutputBaseFilename=成套报价软件_Setup[_\d\.]*', "OutputBaseFilename=成套报价软件_Setup_$new"
|
||||
[System.IO.File]::WriteAllText($iss, $issText, (New-Object System.Text.UTF8Encoding $true))
|
||||
Write-Host "[OK] setup.iss: AppVersion=$new, 安装包名=成套报价软件_Setup_$new.exe"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "版本号已递增至 $new。后续步骤:"
|
||||
Write-Host " 1. 编译主项目(csc @tools\verify_build.rsp)"
|
||||
Write-Host " 2. python tools\make_package.py 组装发布目录"
|
||||
Write-Host " 3. ISCC 编译安装包(文件名自动带 $new)"
|
||||
Write-Host " 4. 更新包(make_update_package.py,目录名建议带版本)"
|
||||
Write-Host " 5. git add+commit+push"
|
||||
Write-Host " 6. Gitea Release: tag 用 v$new"
|
||||
Reference in New Issue
Block a user