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

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

问题描述

这是如何故意复制的使用WiX WIX创建事件日志源吗?使用.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还是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文件在5年内仍然可以工作,即使.Net CLR 2.0和4.0都已降级到Windows 11中的垃圾箱(或当时称为Windows 7的垃圾箱),也很好.

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天全站免登陆