RegistryKeyCopy during major upgrade when RemoveExistingProducts is scheduled after InstallValidate

Feb 11, 2011 at 4:10 AM
Hi.

Thank you for Msi Extensions v1.2.

I have a scenario where RemoveExistingProducts is scheduled after InstallValidate and I would like to use RegistryKeyCopy so that the registry keys are saved before the uninstall of the previous version and then restored if the latest version fails to install.
In this way, the registry keys are not lost and will still exist when trying to run the latest setup installer again.

If I try to use the following schedule in the InstallExecuteSequence:
<Custom Action="Win32_RegistryCopy_Deferred_Install" Before="RemoveExistingProducts">UpgradeCondition</Custom>
<RemoveExistingProducts After="InstallValidate" />
<
Custom Action="WixFailWhenDeferred" After="InstallInitialize"><![CDATA[1]]></Custom>

I get the following error from light.exe:
setup.wxs(1079): error LGHT0204: ICE77: Win32_RegistryCopy_Deferred_Install is a in-script custom action.  It must be sequenced in between the InstallInitialize action and the InstallFinalize action in the InstallExecuteSequence table

C:\Users\dblock\Source\CodePlex\msiext\trunk\src\WixExtensions\SystemToolsExtension\wixlib\SystemToolsExtension.wxs(109): error LGHT0204: ICE77: Win32_RegistryCopy_Rollback is a in-script custom action.  It must be sequenced in between the InstallInitialize action and the InstallFinalize action in the InstallExecuteSequence table

I am using wix v3.0.5419.0.

Any advice?

If I try to use the Win32_RegistryCopy_Immediate_Install custom action instead, I am able to build the msi, but the Win32_RegistryCopy_Rollback custom action does not run after the (new) installation fails (after WixFailWhenDeferred fails for example).

Thank you.
Feb 11, 2011 at 5:12 PM

I am using a RegistryKeyCopy element similar to the following within a <RegistryKey /> element that also contains several <RegistryValue Type="string" /> elements.

<AppSecInc:RegistryKeyCopy Id="RegistryKeyBackupCopy" TargetRoot="HKEY_LOCAL_MACHINE" TargetPath="SOFTWARE\AppSecInc\SystemToolsMsiBackup" CopyOnInstall="yes" RestoreOnRollback="yes" Overwrite="yes" CheckIfExists="yes" />

Feb 11, 2011 at 5:19 PM
Also, notice Action="createAndRemoveOnUninstall" as follows:

<RegistryKey Root="HKLM" Key="SOFTWARE\AppSecInc\SystemToolsMsiBackup" Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="PROPERTY1" Value="[PROPERTY1]" />
...
<AppSecInc:RegistryKeyCopy Id="RegistryKeyBackupCopy" TargetRoot="HKEY_LOCAL_MACHINE" TargetPath="SOFTWARE\AppSecInc\SystemToolsMsiBackup" CopyOnInstall="yes" RestoreOnRollback="yes" Overwrite="yes" CheckIfExists="yes" />
</RegistryKey>

Is this scenario supported with RegistryKeyCopy?

Thank you.
Coordinator
Feb 12, 2011 at 2:17 PM

I don't think you quite understand what those deferred vs. immediate custom actions do. They are not two variants of the same custom action.

These are called "table-driven" custom actions.

  1. At compile time a wix extension processes the wix source XML and creates an MSI table that says what to do. For files for example the table contains the file name and the destination directory.
  2. The immediate custom action prepares a plan of sorts (often called an install script). For example, a FileCopy immediate CA would evaluate conditions and write only those entries that need to be copied in a property. 
  3. The deferred CA does the actual changes. A deferred FileCopy would go through the previously prepared entries and do copy.

So scheduling either is not the way to solve your problem. You need an immediate CA that just does what you want and you can schedule it whenever. For what you're trying to do I think Registry_CopyBranch will do.