build+ui: normalize release version and avoid '+sha' in artifacts\n\n- build.ps1: ensure 3-part SemVer (X.Y.Z) when using git tags; disable IncludeSourceRevisionInInformationalVersion\n- UI: AppVersionShort now tolerates 2-part versions and pads patch with .0
This commit is contained in:
parent
1eb7f13a05
commit
d8ab8d5026
2 changed files with 17 additions and 5 deletions
|
@ -51,9 +51,14 @@ public partial class MainViewModel : ViewModelBase
|
|||
.InformationalVersion ?? "0.0.0";
|
||||
|
||||
private static readonly string s_appVersionShort =
|
||||
Regex.Match(s_appVersion, @"^(\d+)\.(\d+)\.(\d+)").Success
|
||||
? Regex.Match(s_appVersion, @"^(\d+)\.(\d+)\.(\d+)").Value
|
||||
: s_appVersion;
|
||||
(() => {
|
||||
var m = Regex.Match(s_appVersion, @"^(\d+)\.(\d+)(?:\.(\d+))?");
|
||||
if (!m.Success) return s_appVersion;
|
||||
var major = m.Groups[1].Value;
|
||||
var minor = m.Groups[2].Value;
|
||||
var patch = m.Groups[3].Success ? m.Groups[3].Value : "0";
|
||||
return $"{major}.{minor}.{patch}";
|
||||
})();
|
||||
|
||||
public string AppVersion => s_appVersion;
|
||||
public string AppVersionShort => s_appVersionShort;
|
||||
|
|
|
@ -67,7 +67,11 @@ if (-not $Version) {
|
|||
if ($LASTEXITCODE -eq 0 -and $tag) { $Version = $tag.TrimStart('v') }
|
||||
} catch { }
|
||||
}
|
||||
if ($Version) { Write-Host "Using Version: $Version" -ForegroundColor Yellow }
|
||||
if ($Version) {
|
||||
# Normalize to SemVer with 3 numeric segments (X.Y.Z)
|
||||
if ($Version -match '^(\d+)\.(\d+)$') { $Version = "$Version.0" }
|
||||
Write-Host "Using Version: $Version" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# --- Ensure SDK/workloads present ---
|
||||
Invoke-Dotnet --info | Out-Null
|
||||
|
@ -87,6 +91,8 @@ if ($Targets -contains 'win') {
|
|||
'-o', $OutWin
|
||||
)
|
||||
if ($Version) { $args += "-p:Version=$Version" }
|
||||
# Prevent '+<sha>' being appended to informational version in artifacts
|
||||
$args += '-p:IncludeSourceRevisionInInformationalVersion=false'
|
||||
Invoke-InProjectDir -ProjectPath $ProjDesktop @args
|
||||
}
|
||||
|
||||
|
@ -100,6 +106,7 @@ if ($Targets -contains 'web') {
|
|||
'-o', $OutWeb
|
||||
)
|
||||
if ($Version) { $args += "-p:Version=$Version" }
|
||||
$args += '-p:IncludeSourceRevisionInInformationalVersion=false'
|
||||
Invoke-InProjectDir -ProjectPath $ProjWeb @args
|
||||
|
||||
Set-Content -Path (Join-Path $OutWeb 'README.txt') -Value @'
|
||||
|
@ -119,6 +126,7 @@ if ($Targets -contains 'android') {
|
|||
'-o', $OutDroid
|
||||
)
|
||||
if ($Version) { $baseArgs += "-p:Version=$Version" }
|
||||
$baseArgs += '-p:IncludeSourceRevisionInInformationalVersion=false'
|
||||
|
||||
# Unsigned build
|
||||
Invoke-InProjectDir -ProjectPath $ProjAndroid @baseArgs
|
||||
|
@ -140,4 +148,3 @@ Write-Host "`nArtifacts -> $Artifacts" -ForegroundColor Green
|
|||
Write-Host " Windows: $OutWin" -ForegroundColor Green
|
||||
Write-Host " Web: $OutWeb" -ForegroundColor Green
|
||||
Write-Host " Android: $OutDroid" -ForegroundColor Green
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue