1

We have the code below for our Product.wxs. When the installer is run we can see afterward that BackupFiles custom action runs, but RestoreFiles does not run as shown in the log file:

"Skipping action: RestoreFiles (condition is false)"

Why does BackupFiles, with same condition, run and RestoreFiles not run? Has the OLDVERSIONFOUND been changed?


    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
         xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
         xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" >
    
    
      <Product Id="*" Name="My Product" Language="1033" Version="0.0.0.0" Manufacturer="MyCompany"
             UpgradeCode="{B55B9CB0-BA28-4BB3-834B-6075AD5D45E4}">
    
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
        <UIRef Id="WixUI_ErrorProgressText" />
    
    
        <!-- Specify UI -->
        <Property Id="WIXUI_INSTALLDIR" Value="INSTALL_FOLDER" />
        <Property Id="RestoreFiles" Value="INSTALL_FOLDER" />
    
    
    <Upgrade Id="{B55B9CB0-BA28-4BB3-834B-6075AD5D45E4}">
      <UpgradeVersion Minimum="1.0.0"
                      IncludeMinimum="yes"
                      OnlyDetect="no"
                      Maximum="0.0.0.0"
                      IncludeMaximum="no"
                      Property="OLDVERSIONFOUND" />
    </Upgrade>    
    
    <InstallExecuteSequence>
    
        <Custom Action="BackupFiles" After="InstallValidate" >OLDVERSIONFOUND</Custom>
        <Custom Action="SetRestoreFiles" Before="RestoreFiles" />
        <Custom Action="RestoreFiles" After="InstallFiles" >OLDVERSIONFOUND></Custom>
    
    
        <RemoveExistingProducts After="InstallInitialize" />    
    
      </InstallExecuteSequence>
    </Wix>

dgxhubbard
  • 703
  • 2
  • 7
  • 18

1 Answers1

1

Custom actions like these are not really recommended. They can be quite complicated to get right. See links towards the bottom on "settings preservation".

The short version is that settings files should never be installed, but created by the application from defaults or templates (then the setup will never interfere with them), or you can cloud all settings and retrieve on launch from a database. See here, section "cloud-style approaches".


Major Upgrades - Uninstall & Install: There is an important weirdness with major upgrades. You have to remember that you kick off the new installer, and then it will kick of the old installer's uninstall sequence as part of its own operation. Hence a major upgrade will run the uninstall sequence of your old setup and the install sequence of your new setup (potentially in different orders based on configuration of the major upgrade settings).

Counter-Intuitive Effects: This combined "install / uninstall" approach affects logic, conditioning, sequencing and also property values a great deal - and some changes are very counter-intuitive. In addition to two different versions running "at the same time" (or during the same operation), you must also keep in mind that the each installation / uninstallation sequence runs in two different modes: immediate (building execution script) and deferred (executing script executing). With poor conditioning the same custom action could run several times unexpectedly (including in the GUI sequence of the launched setup). Confusing. Debug using message boxes as described towards the bottom here.

Detailed Explanation: This complexity and the phenomenon of property values seemingly changing during installation is attempted explained in detail here: Run Wix Custom action only during uninstall and not during Major upgrade - please read that answer (dual source and all). I will look back later, it is too late for me to run tests tonight.


Throwing in some further links:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164