问题描述
我创建了一个 wixlib 来在一些 wix 项目中共享片段.
我可以使用 PropertyRef 引用在我的主 wix 文件中具有属性的片段,但是如何在需要批量复制其内容的地方引用片段??
例如,我有一个片段来测试是否安装了 .net 框架,我想将该片段包含在项目标签的主 wix 文件中...
这是位于我的 wixlib 中的片段,我想包含在几个 wix 项目中:
I have created a wixlib to share fragments in some wix projects.
I can reference fragments which have Property in my main wix file with a PropertyRef, but how can I reference fragments where I want a bulk copy of its content??
For example I have a fragment which tests if .net framework is installed and I want to include that fragment in my main wix file in the project tag...
Here's the fragment located in my wixlib that I want to include in several wix project:
<Fragment Id="fm35">
<PropertyRef Id="NETFRAMEWORK35" />
<Condition Message="framework 3.5 is not installed">
<![CDATA[Installed OR NETFRAMEWORK35]]>
</Condition>
</Fragment>
谢谢!!
推荐答案
这是一个有趣的问题!教程说任何可以委托给片段的东西都有它的变体标签:FeatureRef功能,PropertyRef 属性等.但是,您问题中的片段内容不会发出任何错误,并且项目构建良好.
That's an interesting question!The tutorial says that anything that can be delegated into a fragment has its variant tag: FeatureRef for Feature, PropertyRef for Property, etc. However, the contents of the fragment in your question doesn't issue any errors and the project builds fine.
不知道是不是故意的,Fragment元素本身没有ref兄弟FragmentRef.由于某种原因,Fragment 元素有一个可选的 Id 属性,但它被指示由高级用户设置以标记部分.我不知道这是什么意思...
I don't know whether it is intentional of not, the Fragment element itself doesn't have a ref brother FragmentRef. For some reason the Fragment element has an optional Id attribute, but it is indicated to be set by advanced users to tag sections. I don't know what it means...
但是,您似乎可以在这里作弊.:-) 向您的 Fragment 添加一个假的 ComponentGroup 元素,它不包含任何真正的组件:
But, it seems you can cheat here. :-) Add a fake ComponentGroup element to your Fragment, which doesn't contain any real Components:
<Fragment>
<PropertyRef Id="NETFRAMEWORK35" />
<Condition Message="framework 3.5 is not installed">
<![CDATA[Installed OR NETFRAMEWORK35]]>
</Condition>
<ComponentGroup Id="Fake" />
</Fragment>
现在,您可以在主 Product.wxs 中引用该 ComponentGroup,整个 Fragment 的内容将按照手册中的承诺包含:
Now, you can reference that ComponentGroup in your main Product.wxs, and the contents of the entire Fragment will be included as promised by the manual:
<Feature Id="ProductFeature" Title="My product feature" Level="1">
<ComponentRef Id="ProductComponent" />
<ComponentGroupRef Id="Fake"/>
</Feature>
只要 ComponentGroup 对 MSI 本身没有任何意义,它就不会给 MSI 包带来垃圾.但它污染了源代码,当然...
As long as ComponentGroup doesn't has any meaning to the MSI itself, it doesn't bring garbage to the MSI package. But it pollutes the source code, of course...
这篇关于如何在 Wix 中包含片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!