【问题标题】:How to create a .NET event log source using WiX如何使用 WiX 创建 .NET 事件日志源
【发布时间】:2012-09-08 04:06:51
【问题描述】:

这是How do you create an event log source using WiXWIX: Create EventSource using .NET message file 的故意半重复。

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

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

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

【问题讨论】:

  • 我同意你的看法。制作这个非常复杂。我有一个更简单的设置(仅针对 .NET 4) - 它仍然很复杂:32 位/64 位操作系统 + .NET 4 客户端配置文件/.NET 4 完整。我有一个可行的解决方案 - 但它不是未来的证明 - 并且代码不是很可读。
  • 莫腾,感谢您的评论。如果您将当前的解决方案发布为我的问题的答案,我将不胜感激,谢谢。

标签: wix event-log wix3.5 eventlog-source


【解决方案1】:

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

1) 添加这些 PropertyRef:

<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>

【讨论】:

  • Morten,这是否意味着安装程序生成的日志将记录在我们提到的任何源下,而不是默认记录在 MsiInstaller 源下?
  • 不,randomuser25995183,正在为已安装的应用程序创建此日志源,以将其用于在系统日志中进行日志记录。
猜你喜欢
  • 2010-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-25
  • 2012-02-03
  • 1970-01-01
  • 2013-01-13
  • 1970-01-01
相关资源
最近更新 更多