1
votes

I'm using wix installer (version 3), I have an msi of version 1.99 and another msi of version 2.00. My app has the ability to do import and export of the DB by calling it with some arguments. I'm trying to perform a major upgrade, and trying to call custom actions before and after the upgrade. Now, the custom action code works just fine. The problem is, that the code that should run BEFORE the old version is removed, is running AFTER it is removed, and thus cannot activate the app and produce the backup files.

In short: How do I time the custom actions to do their work before the removal of the old version?

This is how I call them:

    <CustomAction Id="doExport"
              Return="check"
              Execute="immediate"
              BinaryKey="ImportExportBinary"
              DllEntry="BeforeInstall" />

    <CustomAction Id="doImport"
                Return="check"
                Execute="immediate"
                BinaryKey="ImportExportBinary"
                DllEntry="AfterInstall" />

  <InstallExecuteSequence>
     <Custom Action="doExport" Before="InstallInitialize"> NOT Installed</Custom>
     <Custom Action="doImport" After="InstallFinalize"> NOT Installed</Custom>
  </InstallExecuteSequence>

EDIT:

Here is the major upgrade code:

<MajorUpgrade AllowDowngrades="no" 
                Schedule="afterInstallFinalize"
                DowngradeErrorMessage='Cannot downgrade!' 
                AllowSameVersionUpgrades='yes' ></MajorUpgrade>

I've tried playing a bit with "Execute" attribute of the CustomAction element, without any results.

1

1 Answers

1
votes

First, do your upgrade creating a verbose log to make sure your custom actions are working and being called. You've marked them immediate, so they run before anything changes on the system and so will be called before the old product is removed. When you say "the code works just fine" you probably mean when you run it from your interactive account. But that's not happening. Your code is running out of an msiexec.exe process, the working directory is not what you expect, your code may not be looking in the right place for the files, it will not be elevated and so may not be able to do what it thinks it can. There are many opportunities for your code to not work as expected.

If you ever marked them as deferred I can see why doExport might not work. Without seeing your MajorUpgrade element I can't be sure, but the default scheduling for RemoveExistingProducts is afterInstallValidate. Your custom action is before InstallInitialize, so the actual sequence in the MSI file could easily be InstallValidate, RemoveExistingProducts, doExport, InstallInitialize.

and RemoveExistingProducts that does the uninstall of the old version is before your custom actions.

So if you want to use execute deferred, try Before="RemoveExistingProducts" on your doExport, or use Schedule in your MajorUpgrade to afterInstallInitialize and keep your doExport before InstallInitialize.