From 72fb7180985418f8096aca3c109756f002c9ec13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20G=C3=BCnner?= Date: Wed, 14 Aug 2024 00:37:04 +0200 Subject: [PATCH] Added version suffix support --- .../ControlPanel/Pages/About.xaml.cs | 20 +++++++++++++++- GoAwayEdge/UserInterface/MessageUI.xaml.cs | 23 +++++++++++++++++-- .../UserInterface/Setup/Installer.xaml.cs | 22 +++++++++++++++++- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/GoAwayEdge/UserInterface/ControlPanel/Pages/About.xaml.cs b/GoAwayEdge/UserInterface/ControlPanel/Pages/About.xaml.cs index f5721a6..354c270 100644 --- a/GoAwayEdge/UserInterface/ControlPanel/Pages/About.xaml.cs +++ b/GoAwayEdge/UserInterface/ControlPanel/Pages/About.xaml.cs @@ -14,11 +14,29 @@ public About() { InitializeComponent(); + string versionText; var assembly = Assembly.GetExecutingAssembly(); + var version = Assembly.GetExecutingAssembly().GetName().Version!; + try + { + var informationVersion = assembly.GetCustomAttribute()?.InformationalVersion; + if (!string.IsNullOrEmpty(informationVersion) && version.ToString() != informationVersion) + { + versionText = $"{version}-{informationVersion}"; + } + else + { + versionText = $"{version}"; + } + } + catch + { + versionText = $"{version}"; + } var appDirectory = AppContext.BaseDirectory; var assemblyPath = Path.Combine(appDirectory, $"{assembly.GetName().Name}.exe"); var fvi = FileVersionInfo.GetVersionInfo(assemblyPath); - ValueVersion.Content = $"{fvi.ProductName} v{fvi.FileVersion}"; + ValueVersion.Content = $"{fvi.ProductName} v{versionText}"; ValueCopyright.Content = fvi.LegalCopyright; } diff --git a/GoAwayEdge/UserInterface/MessageUI.xaml.cs b/GoAwayEdge/UserInterface/MessageUI.xaml.cs index 7edfac7..73a1399 100644 --- a/GoAwayEdge/UserInterface/MessageUI.xaml.cs +++ b/GoAwayEdge/UserInterface/MessageUI.xaml.cs @@ -33,8 +33,27 @@ public MessageUi(string title, string message, string? btn1 = null, string? btn2 this.Btn2.Visibility = Visibility.Collapsed; if (btn3 is null or "") this.Btn3.Visibility = Visibility.Collapsed; - - VersionLbl.Content = $"Version {Assembly.GetExecutingAssembly().GetName().Version!}"; + + string versionText; + var assembly = Assembly.GetExecutingAssembly(); + var version = Assembly.GetExecutingAssembly().GetName().Version!; + try + { + var informationVersion = assembly.GetCustomAttribute()?.InformationalVersion; + if (!string.IsNullOrEmpty(informationVersion) && version.ToString() != informationVersion) + { + versionText = $"Version {version}-{informationVersion}"; + } + else + { + versionText = $"Version {version}"; + } + } + catch + { + versionText = $"Version {version}"; + } + VersionLbl.Content = versionText; _mainThread = isMainThread; } diff --git a/GoAwayEdge/UserInterface/Setup/Installer.xaml.cs b/GoAwayEdge/UserInterface/Setup/Installer.xaml.cs index 900d81a..4fe0252 100644 --- a/GoAwayEdge/UserInterface/Setup/Installer.xaml.cs +++ b/GoAwayEdge/UserInterface/Setup/Installer.xaml.cs @@ -19,7 +19,27 @@ public Installer() { InitializeComponent(); - VersionLbl.Content = $"Version {Assembly.GetExecutingAssembly().GetName().Version!}"; + string versionText; + var assembly = Assembly.GetExecutingAssembly(); + var version = Assembly.GetExecutingAssembly().GetName().Version!; + try + { + var informationVersion = assembly.GetCustomAttribute()?.InformationalVersion; + if (!string.IsNullOrEmpty(informationVersion) && version.ToString() != informationVersion) + { + versionText = $"Version {version}-{informationVersion}"; + } + else + { + versionText = $"Version {version}"; + } + } + catch + { + versionText = $"Version {version}"; + } + + VersionLbl.Content = versionText; Configuration.InitialEnvironment(); _welcomePage = new Welcome();