Migrating properties in an installer major upgrade

509 Views Asked by At

Is there any way to view/migrate properties from an installation being removed to the new installation in a major upgrade workflow?

This shouldn't matter too much but here's my context. I'm using MigrateFeatureStates to prevent users from recreating the service during major upgrades. The problem I'm seeing is if a user specifies a custom folder location for the service feature the upgrade fails as the service still uses the custom path while the files are installed to the default location.

Service install/control

<ServiceInstall Id="MyServiceInstall" Name="MyService" DisplayName="MyService" Account="[user]" Password="[pass]" Type="ownProcess" Start="auto" ErrorControl="normal" />
<ServiceControl Id="MyServiceControl" Name="MyService" Wait="yes" Start="install" Stop="both" Remove="uninstall" />

Install sequence

<MigrateFeatureStates Sequence="1001" />
<RemoveExistingProducts Sequence="1020" />
<StopServices Sequence="1700" />
<DeleteServices Sequence="1750"><![CDATA[(NOT UPGRADINGPRODUCTCODE)]]></DeleteServices>
<InstallServices Sequence="5800"><![CDATA[NOT(MIGRATE)]]</InstallServices>
<StartServices Sequence="5900" />
1

There are 1 best solutions below

2
On BEST ANSWER

If you were starting from scratch you'd use the WiX remember property pattern, but if the first product has shipped it's too late.

If the install folder was saved in the registry you could recover it with a WiX registry search. Otherwise you could use a WiX component search. You'd use the component id of the service executable and the search will recover its path. You'd use that in a custom action to set the install folder to that location.

If you are using the WiX major upgrade element then it sets a property called WIX_UPGRADE_DETECTED if you're upgrading, so you could suppress the browse dialog if that property is set.