aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/WixTestTools/BundleUpdateRegistration.cs
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2025-03-20 21:14:12 -0400
committerBob Arnson <bob@firegiant.com>2025-03-24 18:18:52 -0400
commitf3fb208959d5ef2f8df19f518224d413b233f751 (patch)
tree0ef9b5f2e59edb2f25ad0040a1bfa293155c309c /src/test/burn/WixTestTools/BundleUpdateRegistration.cs
parentbf13a0b67dd644eb7d74cb0cfb6876840f73d82b (diff)
downloadwix-bob/UpdateRegistrationAcrossUpgrades.tar.gz
wix-bob/UpdateRegistrationAcrossUpgrades.tar.bz2
wix-bob/UpdateRegistrationAcrossUpgrades.zip
Update registration disappears during upgrade.bob/UpdateRegistrationAcrossUpgrades
Update registration is stored in a shared registry key that Burn takes care to keep around across upgrades. The approach it used broke between WiX v3 and WiX v5. This change makes it work again by writing update registration when the session ends.
Diffstat (limited to 'src/test/burn/WixTestTools/BundleUpdateRegistration.cs')
-rw-r--r--src/test/burn/WixTestTools/BundleUpdateRegistration.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/burn/WixTestTools/BundleUpdateRegistration.cs b/src/test/burn/WixTestTools/BundleUpdateRegistration.cs
new file mode 100644
index 00000000..2ce68122
--- /dev/null
+++ b/src/test/burn/WixTestTools/BundleUpdateRegistration.cs
@@ -0,0 +1,57 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixTestTools
4{
5 using System;
6 using Microsoft.Win32;
7
8 public class BundleUpdateRegistration
9 {
10 public const string BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PACKAGE_NAME = "PackageName";
11 public const string BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PACKAGE_VERSION = "PackageVersion";
12 public const string BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PUBLISHER = "Publisher";
13 public const string BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PUBLISHING_GROUP = "PublishingGroup";
14
15 public string PackageName { get; set; }
16
17 public string PackageVersion { get; set; }
18
19 public string Publisher { get; set; }
20
21 public string PublishingGroup { get; set; }
22
23 public static bool TryGetPerMachineBundleUpdateRegistration(string manufacturer, string productFamily, string name, bool x64, out BundleUpdateRegistration registration)
24 {
25 return TryGetUpdateRegistration(manufacturer, productFamily, name, x64, perUser: false, out registration);
26 }
27
28 public static bool TryGetPerUserBundleUpdateRegistration(string manufacturer, string productFamily, string name, out BundleUpdateRegistration registration)
29 {
30 return TryGetUpdateRegistration(manufacturer, productFamily, name, x64: true, perUser: true, out registration);
31 }
32
33 private static bool TryGetUpdateRegistration(string manufacturer, string productFamily, string name, bool x64, bool perUser, out BundleUpdateRegistration registration)
34 {
35 var baseKey = perUser ? Registry.CurrentUser : Registry.LocalMachine;
36 var baseKeyPath = x64 ? @$"SOFTWARE\{manufacturer}\Updates\{productFamily}\{name}"
37 : @$"SOFTWARE\WOW6432Node\{manufacturer}\Updates\{productFamily}\{name}";
38 using var idKey = baseKey.OpenSubKey(baseKeyPath);
39
40 if (idKey == null)
41 {
42 registration = null;
43 return false;
44 }
45
46 registration = new BundleUpdateRegistration()
47 {
48 PackageName = idKey.GetValue(BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PACKAGE_NAME) as string,
49 PackageVersion = idKey.GetValue(BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PACKAGE_VERSION) as string,
50 Publisher = idKey.GetValue(BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PUBLISHER) as string,
51 PublishingGroup = idKey.GetValue(BURN_UPDATE_REGISTRATION_REGISTRY_BUNDLE_PUBLISHING_GROUP) as string,
52 };
53
54 return true;
55 }
56 }
57}