WiX woes: What is your installer doing?
Summary: How to detect different modes of installation.
When building an application installer, it's often necessary to distinguish between different modes of installation, i.e. initial installation, repair, upgrade, uninstall, etc. And as with everything important in MSI, detecting the mode of installation is a PITA (and by PITA, I do not mean flat bread of Mediterranean origin). To help you a little bit, here is a table adopted from a StackOverflow topic (and comments), that shows the values of various Windows Installer properties can help you determine the installation mode:Install | Uninstall | Repair | Modify | Upgrade | |
INSTALLED | FALSE | TRUE | FALSE | TRUE | TRUE |
REINSTALL | TRUE | FALSE | TRUE | FALSE | FALSE |
REMOVE="ALL" | FALSE | TRUE | FALSE | TRUE | TRUE |
UPGRADINGPRODUCTCODE | TRUE | FALSE | TRUE | TRUE | TRUE |
You can use logical operators NOT, AND, OR to build complex conditions.
Here is how you can detect some common conditions:
First-time installation
- NOT Installed
- NOT Installed AND NOT PATCH
- NOT REMOVE
- NOT Installed OR MaintenanceMode="Modify"
- Installed AND UPGRADINGPRODUCTCODE
- Installed AND NOT REMOVE
- (REMOVE="ALL") AND (NOT UPGRADINGPRODUCTCODE)
- REMOVE~="ALL"
See also:
MSI Property Patterns: Upgrading, FirstInstall and Maintenance
Upgrading, FreshInstall, Maintenance and other MSI convenience properties
MSI Writing Guidelines: Installation Scenarios
How to execute custom action only in install (not uninstall)