Search code examples
wixwindows-installercustom-action

Perform Custom Action Based on Mode - WIX


We have created WIX installer for our application. Problem we are facing is: We have defined two different custom action (say ActionForInstall and ActionForUninstall) that we want to perform in following case: ActionForInstall : Should run while installation, product upgrade, maintenancemode (for both repair and modify) ActionForUninstall : Should run only for uninstallation.

But we are not able to set proper condition. You can refer code :

<Custom Action=ActionForInstall After='InstallFinalize' > 
    (NOT Installed) OR (Installed AND ((MaintenanceMode = "Modify") OR (MaintenanceMode = "Repair")) AND (NOT (MaintenanceMode = "Remove"))) OR  ((UPGRADINGPRODUCTCODE) AND NOT(REMOVE ~= "ALL"))
</Custom>
<Custom Action=ActionForUninstall Before='InstallFinalize'>
    Installed AND NOT UPGRADINGPRODUCTCODE
</Custom>

Please let us know what we have done wrong. Above code is calling InstallFinalize even for uninstall.


Solution

  • You can try these conditions:

    ActionForInstall:

    REMOVE <> "ALL"
    

    ActionForUninstall

    REMOVE = "ALL"