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

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

问题描述

我正在尝试使简单的 Windows 更复杂,但我不知道如何处理.我有两个功能 - 功能 1 和功能 2.我希望仅在用户选择要安装的 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.

我该如何解决这个问题?

How can I fix this?

推荐答案

你需要将你的 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天全站免登陆