How to create a .NET event log source using WiX

风格不统一 提交于 2019-11-28 09:54:24
Morten Frederiksen

As requested. A solution that works on .NET 4 full and .NET 4 client profile using UtilExtension:

1) Add these PropertyRef's:

<PropertyRef Id="NETFRAMEWORK40FULLINSTALLROOTDIR"/>
<PropertyRef Id="NETFRAMEWORK40FULLINSTALLROOTDIR64"/>
<PropertyRef Id="NETFRAMEWORK40CLIENTINSTALLROOTDIR"/>
<PropertyRef Id="NETFRAMEWORK40CLIENTINSTALLROOTDIR64"/>

2) 32 bit part:

<!-- Event Source creation for 32bit OS with .NET 4 Full-->
<Component Id="CreateEventSource32BitFullNet4" Guid="your-guid-here">
    <Condition><![CDATA[NETFRAMEWORK40FULLINSTALLROOTDIR AND NOT VersionNT64]]></Condition>
    <CreateFolder/>
    <!-- Create an Event Source -->
    <Util:EventSource
          xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension"
          Name="YOUR APP NAME"
          Log="Application"
          EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR]EventLogMessages.dll"/>
</Component>

<!-- Event Source creation for 32bit OS with .NET 4 Client Profile-->
<Component Id="CreateEventSource32BitClientNet4" Guid="your-guid-here">
    <Condition><![CDATA[NETFRAMEWORK40CLIENTINSTALLROOTDIR AND NOT VersionNT64]]></Condition>
    <CreateFolder/>
    <!-- Create an Event Source -->
        <Util:EventSource
          xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension"
          Name="YOUR APP NAME"
          Log="Application"
          EventMessageFile="[NETFRAMEWORK40CLIENTINSTALLROOTDIR]EventLogMessages.dll"/>
</Component>

3) 64 bit part:

<!-- Event Source creation for 64bit OS with .NET 4 Full -->
<Component Id="CreateEventSource64BitFullNet4" Guid="your-guid-here">
    <Condition><![CDATA[NETFRAMEWORK40FULLINSTALLROOTDIR64 AND VersionNT64]]></Condition>
    <CreateFolder/>
    <!-- Create an Event Source -->
    <Util:EventSource
          xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension"
          Name="YOUR APP NAME"
          Log="Application"
          EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR64]EventLogMessages.dll"/>
</Component>

<!-- Event Source creation for 64bit OS with .NET 4 Client Profile -->
<Component Id="CreateEventSource64BitClientNet4" Guid="your-guid-here">
    <Condition><![CDATA[NETFRAMEWORK40CLIENTINSTALLROOTDIR64 AND VersionNT64]]></Condition>
    <CreateFolder/>
    <!-- Create an Event Source -->
    <Util:EventSource
          xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension"
          Name="YOUR APP NAME"
          Log="Application"
          EventMessageFile="[NETFRAMEWORK40CLIENTINSTALLROOTDIR64]EventLogMessages.dll"/>
</Component>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!