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}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
build.ps1 = build.ps1
|
build.ps1 = build.ps1
|
||||||
|
Directory.Build.props = Directory.Build.props
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|
|
@ -50,15 +50,20 @@ public partial class MainViewModel : ViewModelBase
|
||||||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
|
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
|
||||||
.InformationalVersion ?? "0.0.0";
|
.InformationalVersion ?? "0.0.0";
|
||||||
|
|
||||||
private static readonly string s_appVersionShort =
|
private static string s_appVersionShort
|
||||||
(() => {
|
{
|
||||||
var m = Regex.Match(s_appVersion, @"^(\d+)\.(\d+)(?:\.(\d+))?");
|
get
|
||||||
if (!m.Success) return s_appVersion;
|
{
|
||||||
var major = m.Groups[1].Value;
|
var m = Regex.Match(
|
||||||
var minor = m.Groups[2].Value;
|
s_appVersion?.Trim() ?? "",
|
||||||
var patch = m.Groups[3].Success ? m.Groups[3].Value : "0";
|
@"^(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?=$|\+)"
|
||||||
return $"{major}.{minor}.{patch}";
|
);
|
||||||
})();
|
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 AppVersion => s_appVersion;
|
||||||
public string AppVersionShort => s_appVersionShort;
|
public string AppVersionShort => s_appVersionShort;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<!-- Centralized app versioning for all projects -->
|
<!-- Centralized app versioning for all projects -->
|
||||||
<PropertyGroup Label="Versioning">
|
<PropertyGroup Label="Versioning">
|
||||||
<!-- Single source of truth: update these -->
|
<!-- Single source of truth: update these -->
|
||||||
<AppVersion>1.1.0</AppVersion>
|
<AppVersion>1.2.0</AppVersion>
|
||||||
<PrereleaseLabel></PrereleaseLabel>
|
<PrereleaseLabel></PrereleaseLabel>
|
||||||
|
|
||||||
<!-- Derived semantic version pieces -->
|
<!-- Derived semantic version pieces -->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue