diff --git a/src/burn/engine/plan.cpp b/src/burn/engine/plan.cpp index 7994dd32f..fe0c62921 100644 --- a/src/burn/engine/plan.cpp +++ b/src/burn/engine/plan.cpp @@ -376,20 +376,6 @@ extern "C" HRESULT PlanDefaultPackageRequestState( break; } } - else if (BOOTSTRAPPER_RELATION_PATCH == relationType && BURN_PACKAGE_TYPE_MSP == packageType) - { - // For patch related bundles, only install a patch if currently absent during install, modify, or repair. - if (BOOTSTRAPPER_PACKAGE_STATE_ABSENT != currentState) - { - *pRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; - } - else if (BOOTSTRAPPER_ACTION_INSTALL == action || - BOOTSTRAPPER_ACTION_MODIFY == action || - BOOTSTRAPPER_ACTION_REPAIR == action) - { - *pRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; - } - } else // pick the best option for the action state and install condition. { hr = GetActionDefaultRequestState(action, currentState, &defaultRequestState); @@ -397,9 +383,23 @@ extern "C" HRESULT PlanDefaultPackageRequestState( if (BOOTSTRAPPER_ACTION_UNINSTALL != action && BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL != action) { + if (BOOTSTRAPPER_RELATION_PATCH == relationType && BURN_PACKAGE_TYPE_MSP == packageType) + { + // For patch related bundles, only install a patch if currently absent during install, modify, or repair. + if (BOOTSTRAPPER_PACKAGE_STATE_ABSENT != currentState) + { + defaultRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; + } + else if (BOOTSTRAPPER_ACTION_INSTALL == action || + BOOTSTRAPPER_ACTION_MODIFY == action || + BOOTSTRAPPER_ACTION_REPAIR == action) + { + defaultRequestState = BOOTSTRAPPER_REQUEST_STATE_PRESENT; + } + } // If we're not doing an uninstall, use the install condition // to determine whether to use the default request state or make the package absent. - if (BOOTSTRAPPER_PACKAGE_CONDITION_FALSE == installCondition) + else if (BOOTSTRAPPER_PACKAGE_CONDITION_FALSE == installCondition) { defaultRequestState = BOOTSTRAPPER_REQUEST_STATE_ABSENT; } diff --git a/src/test/burn/WixToolsetTest.BurnE2E/DependencyTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/DependencyTests.cs index b14b227ed..55534ba3b 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/DependencyTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/DependencyTests.cs @@ -291,6 +291,129 @@ public void CanMinorUpgradeDependencyPackageFromPatchBundleThenUninstallToRestor } } + [RuntimeFact] + public void CanUninstallPatchBundleFromARP() + { + var originalVersion = "1.0.0.0"; + var patchedVersion = "1.0.1.0"; + var testRegistryValue = "PackageA"; + + var packageA = this.CreatePackageInstaller("PackageAv1"); + var packageEv1 = this.CreatePackageInstaller("PackageEv1"); + var packageEv101 = this.CreatePackageInstaller("PackageEv1_0_1"); + var bundleJ = this.CreateBundleInstaller("BundleJ"); + var bundleJ_Patch = this.CreateBundleInstaller("BundleJ_Patch"); + + packageA.VerifyInstalled(false); + packageEv1.VerifyInstalledWithVersion(false); + packageEv101.VerifyInstalledWithVersion(false); + + bundleJ.Install(); + if (this.SupportAddonAndPatchRelatedBundles) + { + bundleJ.VerifyRegisteredAndInPackageCache(); + + packageA.VerifyInstalled(true); + packageA.VerifyTestRegistryValue(testRegistryValue, originalVersion); + packageEv1.VerifyInstalledWithVersion(true); + } + + bundleJ_Patch.Install(); + if (this.SupportAddonAndPatchRelatedBundles) + { + bundleJ_Patch.VerifyRegisteredAndInPackageCache(); + + packageA.VerifyInstalled(true); + packageA.VerifyTestRegistryValue(testRegistryValue, patchedVersion); + packageEv1.VerifyInstalledWithVersion(false); + packageEv101.VerifyInstalledWithVersion(true); + } + + bundleJ_Patch.Uninstall(0, "-burn.related.patch"); + if (this.SupportAddonAndPatchRelatedBundles) + { + bundleJ_Patch.VerifyUnregisteredAndRemovedFromPackageCache(); + packageA.VerifyTestRegistryValue(testRegistryValue, originalVersion); + + // Uninstalling a patch bundle does not uninstall the bundle patch updated msi + //packageEv101.VerifyInstalledWithVersion(false); + } + + bundleJ.Uninstall(); + if (this.SupportAddonAndPatchRelatedBundles) + { + bundleJ.VerifyUnregisteredAndRemovedFromPackageCache(); + bundleJ_Patch.VerifyUnregisteredAndRemovedFromPackageCache(); + + packageA.VerifyInstalled(false); + packageEv1.VerifyInstalledWithVersion(false); + + // Uninstalling a patch bundle does not uninstall the bundle patch updated msi + // https://github.com/wixtoolset/issues/issues/9138 + if (packageEv101.IsInstalledWithVersion()) + { + packageEv101.UninstallProduct(); + } + } + } + [RuntimeFact(Skip = "https://github.com/wixtoolset/issues/issues/9138")] + public void CanUninstallPatchBundleFromARPRemoveUpdatedMSI() + { + var originalVersion = "1.0.0.0"; + var patchedVersion = "1.0.1.0"; + var testRegistryValue = "PackageA"; + + var packageA = this.CreatePackageInstaller("PackageAv1"); + var packageEv1 = this.CreatePackageInstaller("PackageEv1"); + var packageEv101 = this.CreatePackageInstaller("PackageEv1_0_1"); + var bundleJ = this.CreateBundleInstaller("BundleJ"); + var bundleJ_Patch = this.CreateBundleInstaller("BundleJ_Patch"); + + packageA.VerifyInstalled(false); + packageEv1.VerifyInstalledWithVersion(false); + packageEv101.VerifyInstalledWithVersion(false); + + bundleJ.Install(); + if (this.SupportAddonAndPatchRelatedBundles) + { + bundleJ.VerifyRegisteredAndInPackageCache(); + + packageA.VerifyInstalled(true); + packageA.VerifyTestRegistryValue(testRegistryValue, originalVersion); + packageEv1.VerifyInstalledWithVersion(true); + } + + bundleJ_Patch.Install(); + if (this.SupportAddonAndPatchRelatedBundles) + { + bundleJ_Patch.VerifyRegisteredAndInPackageCache(); + + packageA.VerifyInstalled(true); + packageA.VerifyTestRegistryValue(testRegistryValue, patchedVersion); + packageEv1.VerifyInstalledWithVersion(false); + packageEv101.VerifyInstalledWithVersion(true); + } + + bundleJ_Patch.Uninstall(0, "-burn.related.patch"); + if (this.SupportAddonAndPatchRelatedBundles) + { + bundleJ_Patch.VerifyUnregisteredAndRemovedFromPackageCache(); + packageA.VerifyTestRegistryValue(testRegistryValue, originalVersion); + packageEv101.VerifyInstalledWithVersion(false); + } + + bundleJ.Uninstall(); + if (this.SupportAddonAndPatchRelatedBundles) + { + bundleJ.VerifyUnregisteredAndRemovedFromPackageCache(); + bundleJ_Patch.VerifyUnregisteredAndRemovedFromPackageCache(); + + packageA.VerifyInstalled(false); + packageEv1.VerifyInstalledWithVersion(false); + packageEv101.VerifyInstalledWithVersion(false); + } + } + [RuntimeFact] public void CanUninstallBaseWithAddOnsWhenAllSharePackages() {