15

这是对How do you create an event log source using WiX and WIX: 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 或当时所谓的任何东西中都已被归入垃圾箱。

4

1 回答 1

36

按照要求。使用 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>
于 2012-09-20T14:16:56.077 回答