wixupgradewindows-installermajor-upgrade

How to prevent registry delete as part of already installed MSI's uninstallation?


We have an MSI currently in production (say Broker.msi). As part of installation, the MSI (defined in Wix) creates a new registry key(Broker) and adds 2 subkeys under it. After installation, when user registers our product, 1 more registry key called "Key3" is added under "Broker" node. Please note that "Key3" contains registration key which is extremely important & accessed by other layers of the product.

[Registry Structure post install & register]

HKLM\Software\Microsoft\Broker

[Wix Code Snippet]

  <Component Id="RegistryEntries" Guid="*" Win64="$(var.WIN64_COMPONENT)">
          <RegistryKey Root="HKLM" Key="Software\Microsoft\Broker"  Action="createAndRemoveOnUninstall">
            <RegistryValue Type="string" Name="Key1" Value="1rp1users" KeyPath="yes"/>
            <RegistryValue Type="string" Name="Key2" Value="http://windowsbackup/m1" />
          </RegistryKey>
    </Component>
....
 <ComponentRef Id="RegistryEntries" />

Problem: So far since we were using patching, we dint face any issues with the upgrade. From the next release, we want to move to major upgrades but the biggest challenge is : During major upgrade, the old product will get uninstalled. As per the wix snippet, the action element for the "Broker" registry element is "CreateAndRemoveOnUninstall" so the entire "Broker" node is getting deleted, along with the "Key3" subkey.

If I update action to "Create", the problem will get fixed with new installations, but since the msi is already in production how do I prevent it from deleting the registry as part of major upgrade for existing products?


Solution

  • You need to implement the Remember Property pattern. This will cause the new MSI to retrieve the data before the major upgrade removes the old version and then reapply it at the end.