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.

1
  • 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. Commented May 21, 2010 at 17:09

3 Answers 3

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.

4
  • 2
    [WindowsFolder]Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll Commented Feb 18, 2009 at 1:32
  • 9
    If you use the WixNetFxExtension, you can use [NETFRAMEWORK20INSTALLROOTDIR]EventLogMessages.dll
    – Wim Coenen
    Commented Feb 22, 2009 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
    Commented Sep 28, 2010 at 1: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. Commented Nov 25, 2011 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..

3
  • 1
    is it still v2.0.50727 or does a .NET 4 application use v4.0... ?
    – gbjbaanb
    Commented Feb 28, 2013 at 16:27
  • 6
    @gbjbaanb .Net 4.5 uses C:\Windows\Microsoft.NET\Framework\v4.0.30319\EventLogMessages.dll
    – Peter M
    Commented Oct 23, 2014 at 12:48
  • %SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\EventLogMessages.dll
    – Brain2000
    Commented Mar 29, 2023 at 14:03
18

How about the more flexible stuff built in:

EventMessageFile="[NETFRAMEWORK20INSTALLROOTDIR]EventLogMessages.dll"

or

EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR]EventLogMessages.dll"

And

EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR64]EventLogMessages.dll"
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.