64

I'm creating an installer for a website that uses a custom event log source. I would like our WiX based installer to create that event log source during installation.

Does anyone know the best way to do this using the WiX framework.

Edward Wilde
  • 25,967
  • 8
  • 55
  • 64
  • 3
    This is amazing. I was looking for exactly this solution, and thought it was too obscure to possibly already be answered here. Go figure. – Daniel Schaffer May 21 '10 at 17:09

3 Answers3

59

Wix has out-of-the-box support for creating event log sources.

Assuming you use Wix 3, you first need to add a reference to WixUtilExtension to either your Votive project or the command line. You can then add an EventSource element under a component :

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

    <Component ...>
        ...
        <util:EventSource Log="Application" Name="*source name*"
           EventMessageFile="*path to message file*"/>
        ...
    </Component>

If this is a .NET project, you can use EventLogMessages.dll in the framework directory as the message file.

Paul Lalonde
  • 5,020
  • 2
  • 32
  • 35
  • 2
    [WindowsFolder]Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll – David Gardiner Feb 18 '09 at 01:32
  • 9
    If you use the WixNetFxExtension, you can use [NETFRAMEWORK20INSTALLROOTDIR]EventLogMessages.dll – Wim Coenen Feb 22 '09 at 13:03
  • 1
    Just a warning for anyone trying Wim's suggestion; properties can't depend upon the result of other search properties (which `NETFRAMEWORK*` are). Just spent ages trying to figure out why a `DirectorySearch` using `NETFRAMEWORK40CLIENTINSTALLROOTDIR` wasn't working... :P – porges Sep 28 '10 at 01:46
  • One other thing you will need to ensure is that you include -ext "%WIX_BUILD_LOCATION%\WixUtilExtension.dll" on your candle command to use any of the util: features. – Phred Menyhert Nov 25 '11 at 15:41
19

Just to save people some time - if you are trying to use the Application log and the .NET messages you can cut paste the below code:

<Util:EventSource
 xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension"
 Name="ROOT Builder"
 Log="Application"
 EventMessageFile="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll"
/>

NOTE: the path above is now correct..

Peter Tate
  • 2,178
  • 1
  • 21
  • 32
Gordon
  • 3,012
  • 2
  • 26
  • 35
18

How about the more flexible stuff built in:

EventMessageFile="[NETFRAMEWORK20INSTALLROOTDIR]EventLogMessages.dll"

or

EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR]EventLogMessages.dll"

And

EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR64]EventLogMessages.dll"
Daniel Fisher lennybacon
  • 3,865
  • 1
  • 30
  • 38
  • 8
    Not quite correct. In Wix 3.5 it should be [NETFRAMEWORK40FULLINSTALLROOTDIR] or [NETFRAMEWORK40FULLINSTALLROOTDIR64] (for 64bit) - see http://wix.sourceforge.net/manual-wix3/wixnetfxextension.htm. And remember to include a PropertyRef to it. – Simon Brangwin Jul 01 '11 at 01:56