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.
You can try these conditions:
ActionForInstall:
REMOVE <> "ALL"
ActionForUninstall
REMOVE = "ALL"
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With