如何使用 WiX 创建 .NET 事件日志源 [英] How to create a .NET event log source using WiX

查看:21
本文介绍了如何使用 WiX 创建 .NET 事件日志源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 How-do-you-create-an-event-log-source-using-wix">How-do-you-create-an-event-log-source-using-wix">如何您是否使用 WiXWIX:创建 EventSource 创建事件日志源使用 .NET 消息文件.

我的第一个问题是,真的有必要这么复杂吗?是否有某种方法可以简单地指定给 WiX,我的程序是一个 .Net 程序,它需要写入事件日志 - 请进行必要的设置"?

My first question is, does it really have to be so complicated? Isn't there some way to simply specify to WiX, "my program is a .Net program, and it needs to write to the event log - please do the necessary setup"?

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

OK, assuming that isn't possible, I'd like to receive any recommendations for the necessary WiX statements to make it work, irrespective of which version of .Net Framework is installed, and irrespective of whether it is a 32 or 64-bit system. After all, most of my .Net programs are able to run on .Net 2.0 or later, and on either 32 or 64-bit, so it shouldn't matter.

最后一个问题:有什么方法可以让它永不过时?如果我今天生成的 MSI 文件在五年内仍然可以工作,那就太好了,即使 .Net CLR 2.0 和 4.0 在 Windows 11 或当时所谓的任何东西中都已被归入垃圾箱.

Final question: Is there any way to make it future-proof? It would be nice if the MSI files I generate today will still work in five years, even if .Net CLR 2.0 and 4.0 have both been relegated to the dustbin in Windows 11 or whatever it's called then.

推荐答案

根据要求.使用 UtilExtension 在 .NET 4 full 和 .NET 4 客户端配置文件上运行的解决方案:

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

1) 添加这些 PropertyRef:

1) Add these PropertyRef's:

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

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>

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>

这篇关于如何使用 WiX 创建 .NET 事件日志源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆