3

I am trying to install the features based on the condition. Initially i set the feature level to 1 and place a condition inside the feature to modify the feature level.

I am unable to modify the feature level and it is always set to 1 only irrespective of condition.

<Feature
        Id = "AddinsFeature"
        Title  = "InstallAddin"
        Level  = "1"
        Absent="allow">
      <ComponentRef Id = "AddInComp"/>
        <Condition Level="0">
          <![CDATA[FALSE]]>
        </Condition>
</Feature>
Machavity
  • 30,841
  • 27
  • 92
  • 100
123r789
  • 1,600
  • 3
  • 22
  • 33
  • 2
    You should take a closer look at the installation log file. The `INSTALLLEVEL` property can be overridden by a number of other properties. See this link for details: http://msdn.microsoft.com/en-US/library/aa369536.aspx. – Yan Sklyarenko Mar 13 '14 at 07:53
  • **Great note with the log file for debugging.** I had a similar problem and wasted many hours for something simple. After reading so many stuff in the internet and on stack overflow I saw your helping hint. I added log file output to the msiexec command and could see the real problem. For others: Create log files by this: `msiexec /i myInstaller.msi [...] /l myLogfile.txt` – Beauty Feb 03 '21 at 09:35

2 Answers2

1

How to use WiX feature conditions is essentially explained here: https://www.firegiant.com/wix/tutorial/getting-started/conditional-installation/

For a feature to be set to the level specified by your condition, the condition has to evaluate to true. You can force it to be true by setting it to 1:

<Feature Id="AddinsFeature" Title="InstallAddin" Level="1" Absent="allow">

  <!-- Force condition to be true, which sets the feature to the Level attribute value -->
  <Condition Level="0">1</Condition>

  <ComponentRef Id = "AddInComp"/>
</Feature>

Above we force the feature's install level to 0 because its condition of 1 is true (the number 1 is true in MSI logic - by definition - as in boolean). In the real world the condition would be something much more complicated - of course.

Every setup has an overall INSTALLLEVEL - and it acts as a high water mark as explained here by Chris Painter. Every feature which evaluates to a feature level below or at the INSTALLLEVEL gets installed by default.

Note: When you set the Feature level to 0 in your WiX source, the feature is not show in the setup GUI and it is not going to be installed by default either (more details in link below).

Feature manipulation can be very involved. A few links:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
0

You can ship the components present inside the feature by setting the condition 'True' like below. Whenever the property 'SAMPLEFEATURE_UNLOCKED' sets to true, the feature is unlocked. enter image description here

Kathir Subramaniam
  • 1,195
  • 1
  • 13
  • 27