From 44c2ca035c1a5d52a6b3299ba3abbb8b88f7f1c0 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 4 Apr 2022 14:43:06 -0500 Subject: Move the logic of a bundle registering as a system component into Burn. --- src/burn/engine/registration.cpp | 17 +++++++++-------- src/burn/engine/registration.h | 3 +-- src/burn/test/BurnUnitTest/PlanTest.cpp | 22 ++++++++++++++++++++++ .../Bundles/CreateBurnManifestCommand.cs | 9 ++++----- .../BundleFixture.cs | 2 +- .../BundlePackageFixture.cs | 4 ++-- .../DependencyExtensionFixture.cs | 2 +- 7 files changed, 40 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index 7b6aa6bb..961e86bc 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp @@ -169,10 +169,6 @@ extern "C" HRESULT RegistrationParseFromXml( if (fFoundXml) { - // @Register - hr = XmlGetYesNoAttribute(pixnArpNode, L"Register", &pRegistration->fRegisterArp); - ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Register."); - // @DisplayName hr = XmlGetAttributeEx(pixnArpNode, L"DisplayName", &pRegistration->sczDisplayName); ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @DisplayName."); @@ -247,7 +243,12 @@ extern "C" HRESULT RegistrationParseFromXml( // @DisableRemove hr = XmlGetYesNoAttribute(pixnArpNode, L"DisableRemove", &pRegistration->fNoRemove); - ExitOnOptionalXmlQueryFailure(hr, pRegistration->fNoRemoveDefined, "Failed to get @DisableRemove."); + ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @DisableRemove."); + } + + if (pRegistration->fNoRemove && BURN_REGISTRATION_MODIFY_ENABLED != pRegistration->modify) + { + pRegistration->fForceSystemComponent = TRUE; } hr = ParseSoftwareTagsFromXml(pixnRegistrationNode, &pRegistration->softwareTags.rgSoftwareTags, &pRegistration->softwareTags.cSoftwareTags); @@ -759,14 +760,14 @@ extern "C" HRESULT RegistrationSessionBegin( } // NoRemove: should this be allowed? - if (pRegistration->fNoRemoveDefined) + if (pRegistration->fNoRemove) { - hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_NO_REMOVE, (DWORD)pRegistration->fNoRemove); + hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_NO_REMOVE, 1); ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_NO_REMOVE); } // Conditionally hide the ARP entry. - if (!pRegistration->fRegisterArp) + if (pRegistration->fForceSystemComponent) { hr = RegWriteNumber(hkRegistration, REGISTRY_BUNDLE_SYSTEM_COMPONENT, 1); ExitOnFailure(hr, "Failed to write %ls value.", REGISTRY_BUNDLE_SYSTEM_COMPONENT); diff --git a/src/burn/engine/registration.h b/src/burn/engine/registration.h index 58c883da..c07be962 100644 --- a/src/burn/engine/registration.h +++ b/src/burn/engine/registration.h @@ -95,7 +95,7 @@ typedef struct _BURN_SOFTWARE_TAGS typedef struct _BURN_REGISTRATION { BOOL fPerMachine; - BOOL fRegisterArp; + BOOL fForceSystemComponent; BOOL fDisableResume; BOOL fCached; BOOTSTRAPPER_REGISTRATION_TYPE detectedRegistrationType; @@ -140,7 +140,6 @@ typedef struct _BURN_REGISTRATION LPWSTR sczContact; //DWORD64 qwEstimatedSize; // TODO: size should come from disk cost calculation BURN_REGISTRATION_MODIFY_TYPE modify; - BOOL fNoRemoveDefined; BOOL fNoRemove; BURN_SOFTWARE_TAGS softwareTags; diff --git a/src/burn/test/BurnUnitTest/PlanTest.cpp b/src/burn/test/BurnUnitTest/PlanTest.cpp index fcba0f1a..26e7dfd2 100644 --- a/src/burn/test/BurnUnitTest/PlanTest.cpp +++ b/src/burn/test/BurnUnitTest/PlanTest.cpp @@ -71,6 +71,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -231,6 +232,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -364,6 +366,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -479,6 +482,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -579,6 +583,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -698,6 +703,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -800,6 +806,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -894,6 +901,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -983,6 +991,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(TRUE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_NONE, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1058,6 +1067,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1147,6 +1157,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1238,6 +1249,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1344,6 +1356,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1423,6 +1436,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1518,6 +1532,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(TRUE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1588,6 +1603,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1672,6 +1688,7 @@ namespace Bootstrapper Assert::Equal(TRUE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1767,6 +1784,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1861,6 +1879,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -1992,6 +2011,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -2108,6 +2128,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; @@ -2203,6 +2224,7 @@ namespace Bootstrapper Assert::Equal(FALSE, pPlan->fDisableRollback); Assert::Equal(FALSE, pPlan->fDisallowRemoval); Assert::Equal(FALSE, pPlan->fDowngrade); + Assert::Equal(BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_PROVIDER_KEY, pPlan->dwRegistrationOperations); BOOL fRollback = FALSE; DWORD dwIndex = 0; diff --git a/src/wix/WixToolset.Core.Burn/Bundles/CreateBurnManifestCommand.cs b/src/wix/WixToolset.Core.Burn/Bundles/CreateBurnManifestCommand.cs index c0e54300..636c68cb 100644 --- a/src/wix/WixToolset.Core.Burn/Bundles/CreateBurnManifestCommand.cs +++ b/src/wix/WixToolset.Core.Burn/Bundles/CreateBurnManifestCommand.cs @@ -208,7 +208,6 @@ namespace WixToolset.Core.Burn.Bundles writer.WriteAttributeString("ProviderKey", this.BundleSymbol.ProviderKey); writer.WriteStartElement("Arp"); - writer.WriteAttributeString("Register", (this.BundleSymbol.DisableModify || this.BundleSymbol.SingleChangeUninstallButton) && this.BundleSymbol.DisableRemove ? "no" : "yes"); // do not register if disabled modify and remove. writer.WriteAttributeString("DisplayName", this.BundleSymbol.Name); writer.WriteAttributeString("DisplayVersion", this.BundleSymbol.Version); @@ -251,16 +250,16 @@ namespace WixToolset.Core.Burn.Bundles { writer.WriteAttributeString("DisableModify", "yes"); } + else if (this.BundleSymbol.SingleChangeUninstallButton) + { + writer.WriteAttributeString("DisableModify", "button"); + } if (this.BundleSymbol.DisableRemove) { writer.WriteAttributeString("DisableRemove", "yes"); } - if (this.BundleSymbol.SingleChangeUninstallButton) - { - writer.WriteAttributeString("DisableModify", "button"); - } writer.WriteEndElement(); // // Get update registration if specified. diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs index e4a57d4d..45bc284c 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs @@ -120,7 +120,7 @@ namespace WixToolsetTest.CoreIntegration var registrationElements = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Registration"); var registrationElement = (XmlNode)Assert.Single(registrationElements); Assert.Equal($"" + - "" + + "" + "", registrationElement.GetTestXml()); var msiPayloads = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Payload[@Id='test.msi']"); diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundlePackageFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundlePackageFixture.cs index 5f30760e..c2512d6f 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BundlePackageFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundlePackageFixture.cs @@ -109,7 +109,7 @@ namespace WixToolsetTest.CoreIntegration WixAssert.CompareLineByLine(new string[] { $"" + - "" + + "" + "" }, registrations); @@ -196,7 +196,7 @@ namespace WixToolsetTest.CoreIntegration WixAssert.CompareLineByLine(new string[] { $"" + - "" + + "" + "" }, registrations); diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/DependencyExtensionFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/DependencyExtensionFixture.cs index 36855c84..43dbf4f9 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/DependencyExtensionFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/DependencyExtensionFixture.cs @@ -152,7 +152,7 @@ namespace WixToolsetTest.CoreIntegration .ToArray(); WixAssert.CompareLineByLine(new string[] { - "", + "", }, registration); } } -- cgit v1.2.3-55-g6feb