tags:

views:

69

answers:

3

Is it possible to know if an installer is installing/updating/removing in a Custom Action?

We've made a Custom Action dll in C# and it would be interesting if we could detect what the installer is doing. In the WiX xml documents, you could use 'Not Installed', 'REMOVE', etc (see this nice overview). But is it possible to access these variables in a Custom Action?

We tried passing the variable to the Custom Action, but that just gives us a variable with a string value like 'Not Installed', instead of true or false.

A: 

I'm assuming you are using DTF. Is your custom action scheduled for immeadiate or deferred execution?

For immeadiate, you can use session["Installed"] to access the property yourself. For deferred you'll have to use the CustomActionData pattern to serialize/deserialize the data yourself.

Also I typically don't use these properties anyways. I tend to use component and/or feature action states to associate my custom action to a piece of the installed application. This allows for good behavior when doing maintenance operations like adding and removing a feature.

Christopher Painter
Hi, thanks for answering. We sort of worked around the problem. The installers will only be executed by ourselves, so we'll live with the fact that the Custom Action is executed. We receive a MessageBox anyway, so, for a technical user, we can live with it. Also, we have other priorities now. If I recall correctly, however, session["Installed"] didn't work.
Peter
+1  A: 

You can reference the ACTION property.

A custom action in Javascript can get the property like this;

var installAction = Session.Property("ACTION");

The possible values are INSTALL, ADVERTISE, or ADMIN.

If that doesn't do it, I'll bet one of the other built-in properties will satisfy.

Cheeso
A: 

Hm, we ended up making two entry points in the custom action and checking in de wxs files which one we should call. Not how we wanted to do it, but it works for now.

Peter