diff options
Diffstat (limited to '')
| -rw-r--r-- | src/test/burn/WixTestTools/BundleUpdateRegistration.cs | 57 | ||||
| -rw-r--r-- | src/test/burn/WixTestTools/BundleVerifier.cs | 37 |
2 files changed, 94 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 | |||
| 3 | namespace 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 | } | ||
diff --git a/src/test/burn/WixTestTools/BundleVerifier.cs b/src/test/burn/WixTestTools/BundleVerifier.cs index da61d96e..b6181047 100644 --- a/src/test/burn/WixTestTools/BundleVerifier.cs +++ b/src/test/burn/WixTestTools/BundleVerifier.cs | |||
| @@ -6,6 +6,7 @@ namespace WixTestTools | |||
| 6 | using System.IO; | 6 | using System.IO; |
| 7 | using System.Linq; | 7 | using System.Linq; |
| 8 | using System.Text; | 8 | using System.Text; |
| 9 | using System.Xml.Linq; | ||
| 9 | using Microsoft.Win32; | 10 | using Microsoft.Win32; |
| 10 | using WixInternal.TestSupport; | 11 | using WixInternal.TestSupport; |
| 11 | using WixToolset.Data; | 12 | using WixToolset.Data; |
| @@ -23,6 +24,8 @@ namespace WixTestTools | |||
| 23 | 24 | ||
| 24 | private WixBundleSymbol BundleSymbol { get; set; } | 25 | private WixBundleSymbol BundleSymbol { get; set; } |
| 25 | 26 | ||
| 27 | private WixUpdateRegistrationSymbol UpdateRegistrationSymbol { get; set; } | ||
| 28 | |||
| 26 | private WixBundleSymbol GetBundleSymbol() | 29 | private WixBundleSymbol GetBundleSymbol() |
| 27 | { | 30 | { |
| 28 | if (this.BundleSymbol == null) | 31 | if (this.BundleSymbol == null) |
| @@ -36,6 +39,19 @@ namespace WixTestTools | |||
| 36 | return this.BundleSymbol; | 39 | return this.BundleSymbol; |
| 37 | } | 40 | } |
| 38 | 41 | ||
| 42 | private WixUpdateRegistrationSymbol GetUpdateRegistrationSymbol() | ||
| 43 | { | ||
| 44 | if (this.UpdateRegistrationSymbol == null) | ||
| 45 | { | ||
| 46 | using var wixOutput = WixOutput.Read(this.BundlePdb); | ||
| 47 | var intermediate = Intermediate.Load(wixOutput); | ||
| 48 | var section = intermediate.Sections.Single(); | ||
| 49 | this.UpdateRegistrationSymbol = section.Symbols.OfType<WixUpdateRegistrationSymbol>().Single(); | ||
| 50 | } | ||
| 51 | |||
| 52 | return this.UpdateRegistrationSymbol; | ||
| 53 | } | ||
| 54 | |||
| 39 | public string GetFullBurnPolicyRegistryPath() | 55 | public string GetFullBurnPolicyRegistryPath() |
| 40 | { | 56 | { |
| 41 | var bundleSymbol = this.GetBundleSymbol(); | 57 | var bundleSymbol = this.GetBundleSymbol(); |
| @@ -118,6 +134,27 @@ namespace WixTestTools | |||
| 118 | } | 134 | } |
| 119 | } | 135 | } |
| 120 | 136 | ||
| 137 | public bool TryGetUpdateRegistration(out BundleUpdateRegistration registration) | ||
| 138 | { | ||
| 139 | var bundleSymbol = this.GetBundleSymbol(); | ||
| 140 | var x64 = bundleSymbol.Platform != Platform.X86; | ||
| 141 | |||
| 142 | var updateRegistrationSymbol = this.GetUpdateRegistrationSymbol(); | ||
| 143 | var manufacturer = updateRegistrationSymbol.Manufacturer; | ||
| 144 | var productFamily = updateRegistrationSymbol.ProductFamily; | ||
| 145 | var name = updateRegistrationSymbol.Name; | ||
| 146 | |||
| 147 | |||
| 148 | if (bundleSymbol.PerMachine) | ||
| 149 | { | ||
| 150 | return BundleUpdateRegistration.TryGetPerMachineBundleUpdateRegistration(manufacturer, productFamily, name, x64, out registration); | ||
| 151 | } | ||
| 152 | else | ||
| 153 | { | ||
| 154 | return BundleUpdateRegistration.TryGetPerUserBundleUpdateRegistration(manufacturer, productFamily, name, out registration); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | |||
| 121 | public BundleRegistration VerifyRegisteredAndInPackageCache(int? expectedSystemComponent = null) | 158 | public BundleRegistration VerifyRegisteredAndInPackageCache(int? expectedSystemComponent = null) |
| 122 | { | 159 | { |
| 123 | Assert.True(this.TryGetRegistration(out var registration)); | 160 | Assert.True(this.TryGetRegistration(out var registration)); |
