如何在WiX的功能中使用条件? [英] How to use conditions in features in WiX?

查看:56
本文介绍了如何在WiX的功能中使用条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使Windows安装简单,但我不知道该如何处理。
我有两个功能-Feature1和Feature2。我只希望在用户选择要安装Feature1的情况下才安装Feature2。所以我尝试了:

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 the user selected feature1 to be installed. So I tried:

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

<Feature Id='core_perf' Title='core_perf' Description='0MQ core perf' Level='999'>
    <Condition Level="0">NOT (&amp;core = "3")</Condition>
        <ComponentRef Id='cpp_perf' />
</Feature>

但是,如果用户选择功能核心,则不会安装功能core_perf。

But this doesn't install feature core_perf if the user selects feature core.

我该如何解决?

推荐答案

您需要将Condition移至Component定义中,并使用! (功能状态)而不是& (功能动作),以便在您尝试通过再次重新运行安装来添加示例时起作用:

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>

这篇关于如何在WiX的功能中使用条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆