我想生成一个仅包含一项功能的 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 指出此错误:
error LGHT0095 : Multiple primary references were found for Feature 'DefaultFeature' in Product '{...}' and Product '{...}'.
如何更改 wxs 文件以将组件添加到 wxi 文件中定义的功能?
提前致谢。
最佳答案
使用<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。只要主 wx 至少引用另一个 wx 的一个元素,整个内容就会被包含在内。
关于java - 在 wxi 和 wxs 中使用具有相同 Id 的 WIX 功能元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37204816/