4

I created my event source based on this example. My event source looks like this:

[EventSource(Name = "Samples-EventSourceDemos-EventLog")]
public sealed class MinimalEventSource : EventSource
{
    public static MinimalEventSource Log = new MinimalEventSource();

    [Event(1, Message = "{0} -> {1}", Channel = EventChannel.Admin)]
    public void Load(long baseAddress, string imageName)
    {
        WriteEvent(1, baseAddress, imageName);
    }
}

The example use code to simulate install/uninstall process. From some other SO questions, I saw another example of installing event source using event message file.

But it is missing some good examples how to install/register the EventSource that defined by manifests. I am investigating using CustomAction to do something like:

wevtutil.exe im <EtwManifestManFile> /rf:"EtwManifestDllFile" /mf:"EtwManifestDllFile"

but wondering if you have any suggestions?

Community
  • 1
  • 1
Icerman
  • 1,099
  • 4
  • 14
  • 30

2 Answers2

5

Figured out after some search. In the WixUtilExtension, there is build-in support. After referencing it and adding namespace, it is pretty easy.

Here are the changes in the Product.wxs:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
...
      <Component Id="etwManifest.dll">
        <File Id="etwManifest.dll" KeyPath="yes"
              Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll" />
      </Component>
      <Component Id="etwManifest.man">
        <File Id="etwManifest.man" KeyPath="yes"
              Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.man">
          <util:EventManifest  MessageFile="[etwManifest.dll]"  ResourceFile="[etwManifest.dll]"></util:EventManifest>
        </File>
      </Component>
</Wix>

The only trick I had to do is reduce the length of component Id and File Id (used to match with the file names) to avoid the following error: Error 25540. There was a failure while configuring XML files.

Icerman
  • 1,099
  • 4
  • 14
  • 30
  • This installs the event manifest for me, but my process isn't able to log any events. Using WiX 3.9. – Lars Kemmann Jul 01 '15 at 20:14
  • Seems to work for me. If you are using a channel of type "Debug", you will only be able to see it in eventvwr.msc when the option "Show Analytic and Debug Logs" in the view Menu is selected. Make sure you have enabled the log in eventvwr.msc. – BdN3504 May 17 '16 at 11:20
  • I needed to use [#fileId] instead of [fileId] in util:EventManifest element, so: instead of: to make it work. Otherwise the resulting .etwManifest.man file contained empty strings for the references: messageFileName="" resourceFileName="" I found this approach on http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/EventManifest-broken-or-wrong-usage-td7592301.html – anre Dec 03 '20 at 18:46
0

For me, the sollutions was to add permission to both files, the .dll and the .man. (https://stackoverflow.com/a/32727624/5500092)

<util:PermissionEx User="Everyone" ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes" />

I also had to add the full path to correctly registrate the manifest file. When i didn't do that, the manifest file still refer to the bin/release folder of my visual studio solution.

<util:EventManifest MessageFile="[INSTALLFOLDER]SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll" ResourceFile="[INSTALLFOLDER]SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll"/>

Code:

<DirectoryRef Id="INSTALLFOLDER">
    <Component Id="etwManifest.dll" Guid="PUT-GUID-HERE">
        <File Id="etwManifest.dll" KeyPath="yes"  Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll" >
            <util:PermissionEx User="Everyone" ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes" />
             <util:PermissionEx User="Administrators"   ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes"/>
        </File>
    </Component>

    <Component Id="etwManifest.man" Guid="PUT-GUID-HERE">
        <File Id="etwManifest.man" KeyPath="yes" Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.man" >
            <util:PermissionEx User="Everyone"   ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes"/>
            <util:PermissionEx User="Administrators"   ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes"/>
            <util:EventManifest MessageFile="[INSTALLFOLDER]SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll" ResourceFile="[INSTALLFOLDER]SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll"/>
        </File>
    </Component>
</DirectoryRef>

Using WiX Toolset v3.10

(Please do correct me if my English is bad)

Community
  • 1
  • 1
Thomas Devoogdt
  • 816
  • 11
  • 16