Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top