2016-05-13 18 views
1

我想生成僅包含一個功能的MSI軟件包。在wxi和wxs中使用WIX功能元素具有相同的ID

我有一個自動生成的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封裝的光指出這個錯誤:

error LGHT0095 : Multiple primary references were found for Feature 'DefaultFeature' in Product '{...}' and Product '{...}'.

如何更改我的wxs文件以將組件添加到wxi文件中定義的功能?

在此先感謝。

回答

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的元素,整個內容就會被包含。

+0

我無法更改wxi包含文件。這個包含文件是自動生成的。 –

+0

嗯,在這種情況下,您可以指定'Feature =「DefaultFeature」'作爲這些額外組件的屬性,而不是添加具有相同ID的FeatureRef。 –

相關問題