如何使用WiX创建.NET事件日志源

Ren*_*Pet 13 wix eventlog-source event-log wix3.5

这是一个故意半复制的如何使用WiXWIX创建事件日志源:使用.NET消息文件创建EventSource.

我的第一个问题是,它真的必须如此复杂吗?有没有办法简单地指定WiX,"我的程序是一个.Net程序,它需要写入事件日志 - 请做必要的设置"?

好吧,假设这是不可能的,我想收到任何关于必要的WiX语句的建议,以使其工作,无论安装了哪个版本的.Net Framework,无论它是32位还是64位系统.毕竟,我的大多数.Net程序都可以在.Net 2.0或更高版本上运行,在32位或64位运行,所以它无关紧要.

最后一个问题:有没有办法让它面向未来?如果我今天生成的MSI文件仍然可以在五年内运行,那将是很好的,即使.Net CLR 2.0和4.0已经降级到Windows 11中的垃圾箱或者其他所谓的垃圾箱.

Mor*_*sen 34

按照要求.使用UtilExtension的.NET 4 full和.NET 4客户端配置文件的解决方案:

1)添加这些PropertyRef:

<PropertyRef Id="NETFRAMEWORK40FULLINSTALLROOTDIR"/>
<PropertyRef Id="NETFRAMEWORK40FULLINSTALLROOTDIR64"/>
<PropertyRef Id="NETFRAMEWORK40CLIENTINSTALLROOTDIR"/>
<PropertyRef Id="NETFRAMEWORK40CLIENTINSTALLROOTDIR64"/>
Run Code Online (Sandbox Code Playgroud)

2)32位部分:

<!-- 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>
Run Code Online (Sandbox Code Playgroud)

3)64位部分:

<!-- 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>
Run Code Online (Sandbox Code Playgroud)