【问题标题】:Use WIX feature element in wxi and wxs with same Id在具有相同 ID 的 wxi 和 wxs 中使用 WIX 特征元素
【发布时间】:2016-05-13 20:25:07
【问题描述】:

我想生成一个只包含一个功能的 MSI 包。

我有一个自动生成的 wxi 文件。我无法更改此过程。

wxi 文件如下所示:

<?xml version="1.0" encoding="UTF-8" ?>
<Include>
 <!-- components -->
 <Feature Id="DefaultFeature" Title="Main Feature" Level="1">
    <ComponentRef Id="comp0" />
    <ComponentRef Id="comp1" />
    <ComponentRef Id="comp2" />
    <ComponentRef Id="comp3" />
    <ComponentRef Id="CleanupMainApplicationFolder" />
 </Feature>
</Include>

我有一个可以更改的 wxs 文件:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
    <Product ...>
        <!-- components -->
        <?include bundle.wxi ?>
        <UI/>
        <FeatureRef Id="DefaultFeature">
            <ComponentRef Id="comp999" />
        </FeatureRef>
    </Product>
</Wix>

当我将 wxs 编译为 MSI 包时,Light 指出此错误:

错误 LGHT0095:在产品“{...}”和产品“{...}”中找到功能“DefaultFeature”的多个主要引用。

如何更改我的 wxs 文件以将组件添加到 wxi 文件中定义的功能?

提前致谢。

【问题讨论】:

    标签: java javafx deployment wix


    【解决方案1】:

    在包含文件中使用&lt;ComponentGroup&gt; 而不是&lt;Feature&gt;。然后,在一个位置定义您的功能,即带有&lt;Product&gt; 元素的主.wxs 文件。

    例如,这就是包含文件的外观:

    <Fragment>
    <Component Id="Comp1" Guid="{GUID-GOES-HERE}">
      ...
    </Component>
    <Component Id="Comp2" Guid="{GUID-GOES-HERE}">
      ...
    </Component>
    <Component Id="Comp3" Guid="{GUID-GOES-HERE}">
      ...
    </Component>
    
    <ComponentGroup Id="CG1">
      <ComponentRef Id="Comp1"/>
      <ComponentRef Id="Comp2"/>
      <ComponentRef Id="Comp3"/>
    </ComponentGroup>
    </Fragment>
    

    主要的 product.wxs 定义了功能,在其中包含组件组并允许包含更多组件:

    <Feature Id="MainFeature" Title="..." Level="100">
      <ComponentGroupRef Id="CG1"/>
    
      <!-- More components can go here -->
      <Component Id="..">
      </Component>
    </Feature>
    

    此外,您也可以包含 wxs 文件而不是包含。只要主 wxs 至少引用另一个 wxs 中的一个元素,就会包含整个内容。

    【讨论】:

    • 我无法更改 wxi 包含文件。该包含文件是自动生成的。
    • 嗯,在这种情况下,您可以指定 Feature="DefaultFeature" 作为那些额外组件的属性,而不是添加具有相同 Id 的 FeatureRef...
    猜你喜欢
    • 1970-01-01
    • 2022-12-14
    • 2011-02-27
    • 2020-12-21
    • 2017-06-13
    • 1970-01-01
    • 1970-01-01
    • 2017-06-09
    相关资源
    最近更新 更多