How can I perform a custom action in WiX that only executes on install or uninstall?

蹲街弑〆低调 提交于 2020-01-12 12:53:48

问题


I have two custom actions, one of which I'd like to execute when my product is installed and the other when it is uninstalled.

My custom action is currently called from a merge module after the "InstallFinalize", but this happens for both install and uninstall. I've tried adding the "NOT INSTALLED AND NOT UPGRADINGPRODUCTCODE" condition, but that gave me an error:

Error 2762. Cannot write script record. Transaction not started.

I've also tried attaching to other actions (for example, UnpublishComponents), but I can't find any that are unique to install or uninstall.

How can I fix this problem?


回答1:


Try next
1. Only for Installation:

<InstallExecuteSequence>
<Custom Action="SomeAction" After="InstallFinalize">NOT Installed AND NOT REMOVE</Custom>
</InstallExecuteSequence>

2. For Uninstall try to use: Rob's answer

UPGRADINGPRODUCTCODE property is set only during RemoveExistingProducts CA.




回答2:


The variable “INSTALLED” should be using is “Installed”. Find more information regarding the Install and uninstall conditions in the Stack Overflow answer How to add a WiX custom action that happens only on uninstall (via MSI)?.



来源:https://stackoverflow.com/questions/17411913/how-can-i-perform-a-custom-action-in-wix-that-only-executes-on-install-or-uninst

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!