Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX - Retaining registry settings on major upgrade

We are using WiX 3.5 to build an installer for one of our products. For simplicity, we handle version upgrades via a major upgrade, like so:

<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="Laterversionfound" />

We are not specifying the Schedule attribute, which means the RemoveExistingProducts action should run after "InstallValidate" - meaning a full uninstall of the old version will take place, before installing the new version.

We install some HKLM registry settings, which the user must configure following installation. Because the major upgrade performs a full uninstall followed by a reinstall, we are losing the user-defined settings in the registry. Ideally, we need to be able to keep these across upgrades.

My registry key components look like this:

<Component Id="regserver" Guid="[guid]">
    <RegistryValue Root="HKLM" Key="Software\Our Company\Our Product" Name="Server" Value="" Type="string" KeyPath="yes" />
</Component>

I've tried setting the NeverOverwrite property of the components to "yes" but this has the unfortunate effect of failing to recreate the keys - presumably because it checks to see if the keys exist before the uninstall happens (which obviously they do), then they get removed with the uninstall, but not recreated again.

I've also tried setting the "RemoveFeatures" attribute on the MajorUpgrade element to remove everything but the reg keys. This leaves two versions of the product installed though, as the feature containing the reg keys belongs to the old version.

My next step is to try scheduling the RemoveExistingProducts option at a different point, although i'm expecting a certain amount of pain with some of our custom actions.

So my question is, is there any way to achieve what we need, without changing where RemoveExistingProducts is scheduled?

like image 785
Paul Nearney Avatar asked Dec 20 '11 16:12

Paul Nearney


1 Answers

Use RegistrySearch to load the current values into properties then use [PROPERTY] in RegistryValue to write those values. If there isn't an older product installed, the properties will keep their default values.

like image 177
Bob Arnson Avatar answered Nov 19 '22 13:11

Bob Arnson