Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 833
vrajs5 Avatar asked Apr 14 '11 06:04

vrajs5


2 Answers

You can try these conditions:

ActionForInstall:

REMOVE <> "ALL"

ActionForUninstall

REMOVE = "ALL"
like image 143
rmrrm Avatar answered Nov 15 '22 23:11

rmrrm


Usually conditions that use product level properties such as Not Installed and REMOVE="ALL" don't scale to your expectations. It's generally better to use component action states such as

$COMPONENTNAME=3 <-- component being installed locally

$COMPONENTNAME=2 <-- component was previously installed and is now being removed

This will generally cover all of your install, uninstall, maintenance, repair, upgrade scenarios.

You can do similar things for Features using the "&" operator but generally using components "$" is better as components are physical and can be associated to one or more features which are only logical.

And if you really want to take it to the next level, your custom actions could (should) be data driven using a foreign key join to the Component table. In this scenario your custom action always fires and then queries the tables and evaluates the component action states to decide which operations need to be scheduled.

Conditional Statement Syntax (Windows)

like image 30
Christopher Painter Avatar answered Nov 15 '22 23:11

Christopher Painter