【问题标题】:Wix - Add a Component with/without GUID in a ComponentGroupWix - 在 ComponentGroup 中添加带/不带 GUID 的组件
【发布时间】:2018-09-20 01:23:35
【问题描述】:

当我的应用程序想要退出时,通过 windows 日志发生错误,我需要在我的安装程序中添加一个定义 EventMessageFile 的 EventSource,它将成为 .NET Framework 的事件日志消息文件 (我正在关注该解决方案:https://stackoverflow.com/a/574055/6617804)。

在我的 Component.wxs 中,我在这个 ComponentGroup LogsComponents 中添加 Id LogsNet 的组件:

<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),它会导致该错误:

Component/@Guid 属性的值“*”对此组件无效,因为它不符合自动生成 guid 的条件。使用 Directory 作为 KeyPath 或包含 ODBCDataSource 子元素的组件不能使用自动生成的 guid。确保您的组件没有 Directory 作为 KeyPath,并将任何 ODBCDataSource 子元素移动到具有显式组件 guid 的组件。 OptifuelInfomax_Installer (OptifuelInfomax_Installer\OptifuelInfomax_Installer) C:\Source\Infomax\OptiFuelInfomax\OptifuelInfomax_Installer\Components.wxs 80

当我在 Tools -> Create GUID(注册表格式)中使用 Visual Studio 生成 GUID 时,它会在错误列表中显示:

组件元素包含意外的属性“GUID”。 OptifuelInfomax_Installer (OptifuelInfomax_Installer\OptifuelInfomax_Installer) C:\Source\Infomax\OptiFuelInfomax\OptifuelInfomax_Installer\Components.wxs 80

它还在 IDE 中说:不允许使用“GUID”属性。

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

【问题讨论】:

  • Guid 与 GUID 不同,大小写很重要。
  • 是的,属性应该是,例如,Guid="994b5fa4-61dc-4b73-8c5e-f83eed3d7c1a"
  • 你们是对的!在这种特殊情况下,我会尽快更新其他错误

标签: c# wix guid etw-eventsource


【解决方案1】:

它说“不允许使用'GUID'属性”只是因为它不识别属性'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>

【讨论】:

  • 您好,请参阅我对硬编码路径问题的回答,以防止该问题突然意外地打击您。保证硬编码路径迟早会导致问题 - 当然,如果您针对不同的计算机而不是标准化的公司计算机。
【解决方案2】:

还有一件事,我将添加此作为答案以获取链接和免责声明:

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

此外,这里是内置 WiX .NET 属性的文档:WixNetfxExtension(页面下方)。 I would also recommend you install using one file per component。当然不要在同一个组件中安装多个二进制文件——这违反了the component rules。还有a Symantec article on component rules

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-30
    • 2010-11-27
    • 1970-01-01
    • 2011-01-09
    • 1970-01-01
    • 2020-12-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多