Friday, March 20, 2009

WIX EventManifest

Not a blogger. Never will be, because I'm too friggin busy. But I do hate spending hours finding solutions to (undocumented) software problems. As an independent consultant who works on nearly *everything* (linux, unix, windows, mac, c#, c/c++, asp.net, low level crypto, assembler, apache, clustering, computer security, mobile, ...), I spend a lot of time tracking down obscure solutions.

My current project involves using wix (http://wix.sourceforge.net/), an XML --> MSI toolset. It rocks, but the documentation nearly always lags behind the capabilities. One of the items I needed to address was adding a custom event channel to a Vista / W2008 system.

Easy enough - the new event manifest technology makes this "easy" - (see http://msdn.microsoft.com/en-us/library/aa385619(VS.85).aspx and http://msdn.microsoft.com/en-us/magazine/cc163431.aspx), at least during product development.

Getting the event registered and the channel created on the finished product is also "easy" if you use the EventManifest capabilities in Wix 3.0. Here's an example:

Step 1 is to generate and install the resource dll containing the event text - see the msdn links above on how to do this simple op. Include a component with the .dll in your WIX file:

<component id="cEventRes" guid="C27399CA-17DD-4bcb-8414-25D75DA78E63">
<file id="'eventsRES'" name="'events.dll'" diskid="'1'" source="'Z:\myfiles\events.dll'" vital="'yes'">

</component>

Channels, and event messages are defined / registered by calling wevutil on your event manifest. The manifest (a simple XML file) needs to be installed, and registered on the system. This can be tricky using a custom action, but using WIX and the EventManifest tag, its easy. The sort of undocumented part is putting the EventManifest type *inside* of the tag corresponding to the manifest file (that wasn't totally obvious, which is why I blogged this mofo):


<component id="cEvent XML" guid="8A2BF265-1A6E-4667-8962-3662561957B8">
<file id="'eventsXML'" name="'events.xml'" diskid="'1'" source="'Z:\myfiles\eventman.xml'" vital="'yes'">
<util:eventmanifest messagefile="'[#eventsRES]'" resourcefile="'[#eventsRES]'"></util:EventManifest>
</file>
</component>

One important note - you need to include a reference to the WixUtilExtension in your light command line / VS studio project. It also helps w/ intellisense to define the namespace in your .wxs file:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension%22&gt;


That's about all I know about EventManifest and WIX - good luck!