Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 964
Alan Spark Avatar asked Jul 01 '13 19:07

Alan Spark


People also ask

How do I create a custom action on WiX?

You need to create a new C# Custom Action Project for WiX v3 in your solution. Change the function name to a name that fits your function. After that right click on the References Folder on your WiX setup project and choose Add Reference... . Click the tab Projects and choose your custom action Project.

How do I run as administrator in WiX Installer?

Setup tab > Run after execution input: your msi file name. Advanced tab > Mark Request Administrative access option checkbox.

How do I create a WiX Windows Installer?

Go to Tools -> WiX Setup Editor. On the left under Root Directory choose InstallFolder. Under Projects to install, choose the project you want to install. In the red area to the right, you'll see a list of files.


2 Answers

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.

like image 128
Dimiano Avatar answered Sep 25 '22 15:09

Dimiano


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)?.

like image 20
Vinoth Avatar answered Sep 24 '22 15:09

Vinoth