How to use conditions in features in WiX?

前端 未结 2 458
臣服心动
臣服心动 2020-12-29 07:37

I am trying to make simple Windows intaller, and I don\'t know how to deal with this. I have two features - feature1 and feature2. I want feature2 to be installed only if th

相关标签:
2条回答
  • 2020-12-29 08:15

    You need to move your Condition into your Component definition, and use ! (Feature state) instead of & (Feature action) so that it works when you try to add the examples by re-running the install a second time:

    <Component Id="example1">
        <Condition>!feature1 = 3</Condition>
    </Component>
    
    <Component Id="example2">
        <Condition>!feature2 = 3</Condition>
    </Component>
    
    <Feature Id="feature1">
    </Feature>
    
    <Feature Id="feature2">
    </Feature>
    
    <Feature Id="examples">
        <ComponentRef Id="example1" />
        <ComponentRef Id="example2" />
    </Feature>
    
    0 讨论(0)
  • 2020-12-29 08:28

    Have you considered making feature1 the parent of feature2? Then feature2 can't be installed unless feature1 will also be installed. No condition necessary.

    <Feature Id='core' Title='Core' 
             Description='ØMQ 1.0.0 core functionality and C++ API' Level='1'>
        <ComponentRef Id='Core_include' />
        <ComponentRef Id='Core_bin' />
        <ComponentRef Id='Core_lib' />
        <ComponentRef Id='Core_zmq' />
        <ComponentRef Id='cpp_bin' />
        <Feature Id='core_perf' Title='core_perf' Description='0MQ core perf' 
                 Level='999'>
            <ComponentRef Id='cpp_perf' />
        </Feature>
    </Feature>
    
    0 讨论(0)
提交回复
热议问题