From 92442348605ade59319080ccf248cb37ce82fef1 Mon Sep 17 00:00:00 2001
From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com>
Date: Sun, 20 Nov 2022 11:16:51 +0000
Subject: [PATCH] Set uninstall version on install/update (#47)
Version has also been bumped to v1.5.4
---
Bloxstrap/Bloxstrap.csproj | 4 ++--
Bloxstrap/Bootstrapper.cs | 6 +++++-
Bloxstrap/Helpers/Directories.cs | 2 +-
Bloxstrap/Helpers/Updater.cs | 2 ++
Bloxstrap/Program.cs | 3 +++
5 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj
index 6eb15f9..9a8e830 100644
--- a/Bloxstrap/Bloxstrap.csproj
+++ b/Bloxstrap/Bloxstrap.csproj
@@ -10,8 +10,8 @@
AnyCPU
AnyCPU;x86
Bloxstrap.ico
- 1.5.3
- 1.5.3.0
+ 1.5.4
+ 1.5.4.0
diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs
index 5db507b..e2b20aa 100644
--- a/Bloxstrap/Bootstrapper.cs
+++ b/Bloxstrap/Bootstrapper.cs
@@ -284,7 +284,11 @@ namespace Bloxstrap
RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{Program.ProjectName}");
uninstallKey.SetValue("DisplayIcon", $"{Directories.App},0");
uninstallKey.SetValue("DisplayName", Program.ProjectName);
- uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd"));
+ uninstallKey.SetValue("DisplayVersion", Program.Version);
+
+ if (uninstallKey.GetValue("InstallDate") is null)
+ uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd"));
+
uninstallKey.SetValue("InstallLocation", Directories.Base);
uninstallKey.SetValue("NoRepair", 1);
uninstallKey.SetValue("Publisher", Program.ProjectName);
diff --git a/Bloxstrap/Helpers/Directories.cs b/Bloxstrap/Helpers/Directories.cs
index 3d49b0f..93462e2 100644
--- a/Bloxstrap/Helpers/Directories.cs
+++ b/Bloxstrap/Helpers/Directories.cs
@@ -2,7 +2,7 @@
namespace Bloxstrap.Helpers
{
- internal class Directories
+ class Directories
{
public static string Base { get; private set; } = "";
public static string Downloads { get; private set; } = "";
diff --git a/Bloxstrap/Helpers/Updater.cs b/Bloxstrap/Helpers/Updater.cs
index 942376a..a6a8695 100644
--- a/Bloxstrap/Helpers/Updater.cs
+++ b/Bloxstrap/Helpers/Updater.cs
@@ -34,6 +34,8 @@ namespace Bloxstrap.Helpers
File.Delete(Directories.App);
File.Copy(Environment.ProcessPath, Directories.App);
+ Bootstrapper.Register();
+
Program.ShowMessageBox(
$"{Program.ProjectName} has been updated to v{currentVersionInfo.ProductVersion}",
MessageBoxIcon.Information,
diff --git a/Bloxstrap/Program.cs b/Bloxstrap/Program.cs
index 980fc82..3292d79 100644
--- a/Bloxstrap/Program.cs
+++ b/Bloxstrap/Program.cs
@@ -10,6 +10,7 @@ using Bloxstrap.Models;
using Bloxstrap.Dialogs;
using System.Net.Http;
using System.Net;
+using System.Reflection;
namespace Bloxstrap
{
@@ -34,6 +35,8 @@ namespace Bloxstrap
public static string LocalAppData { get; private set; } = null!;
public static string StartMenu { get; private set; } = null!;
+ public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
+
public static SettingsManager SettingsManager = new();
public static SettingsFormat Settings = SettingsManager.Settings;
public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All });