wixwindows-installercustom-actionwix3.11

Wix custom action to execute only during install but not on upgrade and remove?


I have a custom action that has to execute only during install but not during minor release upgrade and remove? I tried with different conditions but the CA is executing during minor release.

1) (NOT Installed) OR NOT(REMOVE="ALL" AND UPGRADINGPRODUCTCODE)

2) (NOT Installed)

3) (NOT Installed) OR NOT(Installed AND REMOVE="ALL" AND UPGRADINGPRODUCTCODE)

but nothing works for me. And my CA is executing twice may be because during upgrade the setup is uninstalling and installing. Any suggestions how to execute CA only during install but not during upgrades.


Solution

  • Please Test: You could try with (NOT Installed) AND (NOT WIX_UPGRADE_DETECTED) as a first test (see this answer), and then use the debugging approach below to test properly. No guarantees! Conditions are notorious.

    Top Tip: MSI conditions are notoriously fiddly to get right. You can debug MSI conditions pretty efficiently by the approach described here: How to execute conditional custom action on install and modify only? (see bottom section - using VBScript message boxes and then run the setup in different modes).

    Minor Upgrades: Please be aware that minor upgrades are very limited - and another answer. Please review the restrictions to make sure you are aware of them and that you can release your software with them in mind. Also make sure to test repair and modify scenarios for the installer.

    Advice: Often it is better to use the launch sequence of the application to perform application configuration than relying on custom actions since they have complex sequencing, conditioning and impersonation issues.