wixwix3.7wix3.8

Wix if and else if condition inside component element


I have a .wxs file for program installation. I want to pass a part of installation depending on the IIS version (for ex. execute if IIS verion > #10 set something and else if <= #7 set something ) and continue to install other parts.


Solution

  • In Windows Installer, components are the smallest units of installation/removal. They are entities that can be part of multiple products. For a product, only a feature can be selected for installation or removal. (When no product's installed features need a component, it is removed. When a product has no installed features, it is removed.)

    A component can be in multiple features. A feature can have a condition on it. (They aren't just for user selection in a dialog.) Features can be nested.

    Putting it together, it seems that you need to conditionally select features.

    In WiX, you can express features, conditions and component references as in this answer to a similar question.

    You might use the WiX-provided IIS version detection in your conditions like this:

    <PropertyRef Id="IISMAJORVERSION" /> 
    <PropertyRef Id="IISMINORVERSION" />
    …
    
    <Condition Level="1"><![CDATA[IISMAJORVERSION >= "#10"]]></Condition>