Reputation: 4844
I am using Wix 3.8.
At first, I create an installer (.msi) that executes a custom action during installation process (for test purposes it only shows a message):
Product Element:
<Product Id="PUT-GUID-HERE" Name="MyProduct"
Version="1.0.1.100" Manufacturer="Foobar Company"
UpgradeCode="PUT-GUID-HERE">
Custom Action
<CustomAction Id="Message1" Script="vbscript">
<![CDATA[
MsgBox("First Install?")
]]>
</CustomAction>
<InstallExecuteSequence>
<Custom Action="Message1"
Before="InstallInitialize">NOT Installed AND NOT REMOVE</Custom>
Now when I execute my .msi file, the message will be shown on my installation:
At next, I modify my product code and increase my version number to build an update:
Product Element:
<Product Id="PUT-GUID-HERE"
Name="MyProduct" Version="1.0.2.100"
Manufacturer="Foobar Company"
UpgradeCode="PUT-GUID-HERE">
Regarding the condition NOT Installed AND NOT REMOVE
I expect, that the message box does not appear when I execetue the update. But it does:
What is the correct condition for a custom action that only will be executed on install but not on update?
Upvotes: 1
Views: 5327
Reputation: 42226
Be careful with the conditions on custom actions, they are complicated to get right. Here is a MSI Conditions Cheat Sheet to help you. I have not tested these conditions - testing is the only guarantee. Here is another sheet with more advanced info (recommended).
Here is an interesting post: How to add a WiX custom action that happens only on uninstall (via MSI)?
Your suggested condition looks ok, but have a look at the sheet. Also - a patch features patch-specific properties such as PATCH and MSIPATCHREMOVE. Use these conditions on custom actions to make them run or not run during a patch depending on what is necessary. If you plan to use patches you should condition your custom actions to not run during patching in my opinion.
I eliminated the hard coded guids for you. Be careful posting guids - with a simple copy and paste your unique guids are not so unique any more. Genuine problems could result from all hard coded guids.
Upvotes: 3
Reputation: 4844
Finally it woks with following condition:
NOT (WIX_UPGRADE_DETECTED OR UPGRADINGPRODUCTCODE) AND NOT (REMOVE="ALL")
Using this condition, my action only reacts on install, but not on update and not on uninstall.
Important: The .msi of both, the installer and update must contain that condition.
Upvotes: 2