在wxi和wxs中使用具有相同Id的WIX特征元素

时间:2016-05-13 08:18:35

标签: java javafx deployment wix

我想生成一个只包含一个功能的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文件中定义的功能?

提前致谢。

1 个答案:

答案 0 :(得分:0)

在包含文件中使用<ComponentGroup>而不是<Feature>。然后,在一个位置定义您的功能,主.wxs文件包含<Product>元素。

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

<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文件而不是include。只要主wxs引用另一个wxs中的至少一个元素,就会包含整个内容。