Wix Installer: One feature with condition to decide which ComponentGroupRef to use

▼魔方 西西 提交于 2020-01-03 04:24:06

问题


My installer has a Feature called "Tools"

What is installed by this feature is dependent on which version of SQL Server the client is running.

How can I have one feature with a condition that says "If SQL 2008 do ComponentGroupRef ID=SQL2008 otherwise ComponentGroupRef ID=SQL2012"

I'm creating 2 properties to hold the directory for SQL2008 and SQL2012, so those are the properties I'm using to make my determination.

This is close, but shows "Tools" feature twice.

<Feature Id="SQL2008Tools" Title="Tools" Level="1" Description="Installs all support UI Tools for SQL 2008">
      <Condition Level="1"><![CDATA[SQL2008BINDIR AND NOT SQL2012BINDIR]]></Condition>
      <ComponentGroupRef Id="Tools2008Component"/>
    </Feature>

    <Feature Id="SQL2012Tools" Title="Tools" Level="1" Description="Installs all support UI Tools for SQL 2012">
      <Condition Level="1"><![CDATA[SQL2012BINDIR]]></Condition>
      <ComponentGroupRef Id="Tools2012Component"/>
    </Feature>   

As always - thanks for any help!


回答1:


As you've found the title of a feature does not have to be unique. You have two features with the same title so it shows that way.

Try using nested features:

<Feature Id="SQLTools" Title="Tools" Level="1" Description="Installs support UI Tools for SQL Server"> 
  <Feature Id="SQL2008Tools" Title="SQL 2008 Tools" Level="1" Description="Installs all support UI Tools for SQL 2008">
    <Condition Level="1"><![CDATA[SQL2008BINDIR AND NOT SQL2012BINDIR]]></Condition>
    <ComponentGroupRef Id="Tools2008Component"/>
  </Feature>

  <Feature Id="SQL2012Tools" Title="SQL 2012 Tools" Level="1" Description="Installs all support UI Tools for SQL 2012">
    <Condition Level="1"><![CDATA[SQL2012BINDIR]]></Condition>
    <ComponentGroupRef Id="Tools2012Component"/>
  </Feature> 
</Feature> 


来源:https://stackoverflow.com/questions/25815446/wix-installer-one-feature-with-condition-to-decide-which-componentgroupref-to-u

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