0

I have an existing WIX installer file that I'm trying to figure out. In this file I see two custom actions defined:

<Custom Action="CreateBackup"     Before="InstallInitialize">            
    <![CDATA[Installed]]>
</Custom>

<Custom Action="RestoreBackup"    After= "InstallFinalize">
    <![CDATA[NOT Installed]]>
</Custom>

The CreateBackup function copies some files (not directly related to this installer) from a remote location. Restore puts those files back at the same location.

Now in an upgrade scenario I see the following logging order. I have put the apparent value of "Installed" in brackets:

  • CreateBackup is skipped (Installed == false)
  • InstallInit
  • CreateBackup succeeds (Installed == true)
  • InstallInit
  • InstallFinalize
  • RestoreBackup is skipped (Installed == true)
  • InstallFinalize
  • RestoreBackup succeeds (Installed == false)

I have a couple of questions about this:

  • I understand that there is an uninstall and an install going in this script. And based on the value of "Installed" I conclude that the install is done first. Is this correct?
  • I see that the InstallInit is called twice before the first InstallFinalize. What does this mean? Is the installation still busy when uninstall begins?
  • The first value of Installed is false, so I guess it is relative to the new version? But how does it become false again after the deinstallation finishes? Is it relative to the old version then?

I am using an MajorUpgrade element.

Hope someone can clear this up.

Frank
  • 2,446
  • 7
  • 33
  • 67

1 Answers1

1

I'm assuming that you are using a WiX MajorUpgrade element to do your upgrade, so the conditions you need should be something like this:

When you are doing an upgrade the WIX_UPGRADE_DETECTED property is set when an upgrade is being done:

http://wixtoolset.org/documentation/manual/v3/xsd/wix/majorupgrade.html

So use that condition when you want to create the backup, assuming that you want to do the backup of existing files (from the older product) when doing the upgrade.

It's not clear from your post exactly when you want to do the restore but if it's after the upgrade then use the same WIX_UPGRADE_DETECTED property.

Those conditions based on the Installed property don't seem to make a lot of sense because the property is set if the current MSI's ProductCode is installed. In a upgrade at that stage it will always be unset.

This post has more info about properties and install actions:

How to add a WiX custom action that happens only on uninstall (via MSI)?

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • It is indeed a majorupgrade element. I did not know this was relevant :). I'm not actually trying to fix something, I am trying to understand the flow of the current implementation. How does the "Installed" property change during an upgrade? What the backup and restore do is save some files from a remote location (not directly related to this installer) on the disk. Restore puts those files back. I have updated my question to make it a bit clearer. – Frank Jul 26 '17 at 09:36