I have a custom action which I need to execute only once during install or upgrading.
What happens is that the custom action is being executed twice if there is an older version of the same product already installed on the system. However the custom action is executed only once when there is no previous version installed on the system (clean install).
I have modified the condition for the custom action. Now when upgrading the custom action is only called once (which is correct) but in a clean install (with no previous version installed) the custom action is not being executed.
<CustomAction Id="MyCustomAction"
Return="check"
Execute="deferred"
Impersonate="no"
BinaryKey="MyCustomActions.CA.dll"
DllEntry="MyCustomAction" />
<InstallExecuteSequence>
<Custom Action="MyCustomAction"
Before="InstallFinalize">
<![CDATA[NOT Installed AND UPGRADINGPRODUCTCODE]]>
</Custom>
</InstallExecuteSequence>
Current behavior: Custom action is only executed once when upgrading but it is never called when installing.
Expected behavior: Custom action is executed only once when upgrading or installing.