From 6d7b14b40f01ca244a1dec6fa63b997a9246193c Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:54:45 -0400 Subject: [PATCH 1/2] Specify WPF version in AssemblyInfo This fixes an issue with upgrading settings since the default settings provider uses the assembly version for upgrading. --- TwitchDownloaderWPF/MainWindow.xaml.cs | 4 +++- TwitchDownloaderWPF/Properties/AssemblyInfo.cs | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/TwitchDownloaderWPF/MainWindow.xaml.cs b/TwitchDownloaderWPF/MainWindow.xaml.cs index d429aefc..008ca79b 100644 --- a/TwitchDownloaderWPF/MainWindow.xaml.cs +++ b/TwitchDownloaderWPF/MainWindow.xaml.cs @@ -3,11 +3,13 @@ using System.Diagnostics; using System.IO; using System.Net; +using System.Reflection; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; using System.Windows.Interop; +using TwitchDownloaderWPF.Extensions; using TwitchDownloaderWPF.Properties; using TwitchDownloaderWPF.Services; using Xabe.FFmpeg; @@ -88,7 +90,7 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) // it will sometimes start behind other windows, usually (but not always) due to the user's actions. FlashTaskbarIconIfNotForeground(TimeSpan.FromSeconds(3)); - var currentVersion = Version.Parse("1.55.0"); + var currentVersion = Assembly.GetExecutingAssembly().GetName().Version!; #if DEBUG Title = $"Twitch Downloader v{currentVersion} - DEBUG"; #else diff --git a/TwitchDownloaderWPF/Properties/AssemblyInfo.cs b/TwitchDownloaderWPF/Properties/AssemblyInfo.cs index 2128e947..910cd3f4 100644 --- a/TwitchDownloaderWPF/Properties/AssemblyInfo.cs +++ b/TwitchDownloaderWPF/Properties/AssemblyInfo.cs @@ -51,5 +51,4 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.55.0")] From 56dd06beaf274c616b7170651147f907eae02553 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:57:05 -0400 Subject: [PATCH 2/2] Strip revision from assembly version --- TwitchDownloaderWPF/Extensions/VersionExtensions.cs | 9 +++++++++ TwitchDownloaderWPF/MainWindow.xaml.cs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 TwitchDownloaderWPF/Extensions/VersionExtensions.cs diff --git a/TwitchDownloaderWPF/Extensions/VersionExtensions.cs b/TwitchDownloaderWPF/Extensions/VersionExtensions.cs new file mode 100644 index 00000000..f461f9fb --- /dev/null +++ b/TwitchDownloaderWPF/Extensions/VersionExtensions.cs @@ -0,0 +1,9 @@ +using System; + +namespace TwitchDownloaderWPF.Extensions +{ + public static class VersionExtensions + { + public static Version StripRevisionIfDefault(this Version version) => version.Revision < 1 ? new Version(version.Major, version.Minor, version.Build) : version; + } +} \ No newline at end of file diff --git a/TwitchDownloaderWPF/MainWindow.xaml.cs b/TwitchDownloaderWPF/MainWindow.xaml.cs index 008ca79b..d99f7f5b 100644 --- a/TwitchDownloaderWPF/MainWindow.xaml.cs +++ b/TwitchDownloaderWPF/MainWindow.xaml.cs @@ -90,7 +90,8 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) // it will sometimes start behind other windows, usually (but not always) due to the user's actions. FlashTaskbarIconIfNotForeground(TimeSpan.FromSeconds(3)); - var currentVersion = Assembly.GetExecutingAssembly().GetName().Version!; + // Despite not specifying a revision in the AssemblyVersion, the compiler still adds one. We don't want that. + var currentVersion = Assembly.GetExecutingAssembly().GetName().Version!.StripRevisionIfDefault(); #if DEBUG Title = $"Twitch Downloader v{currentVersion} - DEBUG"; #else