Fixing Version Number Display
This commit is contained in:
parent
d8ab8d5026
commit
e911615845
3 changed files with 16 additions and 10 deletions
|
@ -14,6 +14,7 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
build.ps1 = build.ps1
|
||||
Directory.Build.props = Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
|
|
|
@ -50,15 +50,20 @@ public partial class MainViewModel : ViewModelBase
|
|||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
|
||||
.InformationalVersion ?? "0.0.0";
|
||||
|
||||
private static readonly string s_appVersionShort =
|
||||
(() => {
|
||||
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}";
|
||||
})();
|
||||
private static string s_appVersionShort
|
||||
{
|
||||
get
|
||||
{
|
||||
var m = Regex.Match(
|
||||
s_appVersion?.Trim() ?? "",
|
||||
@"^(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?=$|\+)"
|
||||
);
|
||||
if (!m.Success) return s_appVersion ?? "Unknown Version";
|
||||
|
||||
// Return exactly what’s present (major | major.minor | major.minor.patch)
|
||||
return m.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public string AppVersion => s_appVersion;
|
||||
public string AppVersionShort => s_appVersionShort;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<!-- Centralized app versioning for all projects -->
|
||||
<PropertyGroup Label="Versioning">
|
||||
<!-- Single source of truth: update these -->
|
||||
<AppVersion>1.1.0</AppVersion>
|
||||
<AppVersion>1.2.0</AppVersion>
|
||||
<PrereleaseLabel></PrereleaseLabel>
|
||||
|
||||
<!-- Derived semantic version pieces -->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue