gthvmt
gthvmt

Reputation: 13

Wix v4: Run custom action only on install

In wix 3 you could specify a condition inside the custom element.

In wix 4 the same element does not seem to accept inner text anymore. If you try to set a condition the compiler throws a The Custom element contains illegal inner text: 'NOT Installed AND NOT UPGRADINGPRODUCTCODE' error. How would one go ahead and only run the custom action during the installation now?

Upvotes: 1

Views: 1912

Answers (3)

Christopher Painter
Christopher Painter

Reputation: 55581

Pro Tip: WiX's v3 to v4 code converter is really good. Author what you know in v3 and then convert it v4 and diff the before and after to quickly learn new changes in v4.

Upvotes: 0

Bob Arnson
Bob Arnson

Reputation: 21886

Condition is an attribute on the Custom element: https://wixtoolset.org/docs/reference/schema/wxs/custom/

Upvotes: 2

gthvmt
gthvmt

Reputation: 13

I ended up checking the REMOVE parameter inside the custom action itself to check whether it got called during a uninstall and then run the logic accordingly.

var isUninstall = session["REMOVE"] == "ALL";

The only problem with that solution is that this way I cant make sure that the custom action logic does not run on patches as well.

Upvotes: 0

Related Questions