How to include fragments in Wix?

余生长醉 提交于 2019-11-30 17:37:45

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.

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...

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>

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>

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...

Back in the old days of wix 2 we used to have FragmentRef elements. It was very easy to include any fragment in your Product section and it was very easy for anyone reading the xml to figure out what was being done.

<FragmentRef Id="CustomActionFrag" />
<FragmentRef Id="PropertiesFrag" />

Now in wix 3 they have eliminated the FragmentRef element. Not sure why. I find it very anoying, because in my Product element I have to add several references to "something defined in my fragments"

<CustomActionRef Id="caDoSomething"/>
<PropertyRef Id="PropCryptic"/>

If I don't do that the fragment is completely ignored and does not make its way into the final MSI.

That's very cryptic for anyone reading the xml. Give my FragmentRef's back!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!