Wix - 在组件组中添加组件 with/without GUID

Wix - Add a Component with/without GUID in a ComponentGroup

当我的应用程序想要退出时,通过 windows 日志出现错误,我需要在我的安装程序中添加一个定义 EventMessageFile 的 EventSource,它将成为 .NET Framework 的事件日志消息文件 (我正在遵循该解决方案:)。

在我的 Component.wxs 中,我在这个 ComponentGroup LogsComponents[ 中添加了 Id LogsNet 的组件=35=] :

<ComponentGroup Id="LogsComponents" Directory="LogsFolder">
  <Component Id="Logs" Guid="{339873E0-0984-4A1B-8C53-0F64DFAD56BC}">
    <File Id="..." Source="..." />
    <File Id="..." Source="..." />
    <File Id="..." Source="..." />
    <File Id="..." Source="..." />
    <RemoveFolder Id='LogsFolder' On='uninstall' />
    <RegistryValue Root='HKCU'
                       Key='Software\[Manufacturer]\[ProductName]'
                       Type='string'
                       Value=''
                       KeyPath='yes' />
  </Component>

  <Component Id="LogsNET" >
    <util:EventSource
       Log="Application" Name="ROOT Builder"
       EventMessageFile="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll"/>
  </Component>
</ComponentGroup>

当我尝试以这种方式添加它时 (不生成 GUID),它会导致错误:

The Component/@Guid attribute's value '*' is not valid for this component because it does not meet the criteria for having an automatically generated guid. Components using a Directory as a KeyPath or containing ODBCDataSource child elements cannot use an automatically generated guid. Make sure your component doesn't have a Directory as the KeyPath and move any ODBCDataSource child elements to components with explicit component guids. OptifuelInfomax_Installer (OptifuelInfomax_Installer\OptifuelInfomax_Installer) C:\Source\Infomax\OptiFuelInfomax\OptifuelInfomax_Installer\Components.wxs 80

当我在工具->创建GUID(注册表格式)中使用Visual Studio生成GUID时,它说在错误列表中:

The Component element contains an unexpected attribute 'GUID'. OptifuelInfomax_Installer (OptifuelInfomax_Installer\OptifuelInfomax_Installer) C:\Source\Infomax\OptiFuelInfomax\OptifuelInfomax_Installer\Components.wxs 80

它还在 IDE 中说:'GUID' 属性是不允许的。

我应该为该组件使用 GUID 吗?

它说 "The 'GUID' attribute is not allowed" 只是因为它不识别属性 'GUID' - 它区分大小写; 真正的属性名称是'Guid',所以它正在编译:

<Component Id="LogsNET" Guid ="{...blah123...}">
    <util:EventSource
       Log="Application" Name="ROOT Builder"
       EventMessageFile="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll"
       KeyPath="yes"/>
  </Component>

还有一件事,我会将其添加为获取链接和免责声明的答案:

我没做过多少 EventMessageFile 安装,但我只想补充一点 硬编码路径总是错误的 (您对 %SystemRoot% 的使用可能仍然有效)。您无疑知道,系统分区不是 C:\ 的情况并不少见。请查看此特定答案(这是您链接到自己的 "thread" 的特定答案),了解如何消除硬编码路径:How do you create an event log source using WiX.

此外,这里还有 built-in WiX .NET 属性的文档:WixNetfxExtension (a bit down the page). I would also recommend you install using one file per component. Certainly do not install multiple binaries in the same component - this is a violation of the component rules. And a Symantec article on component rules