我正在尝试制作简单的Windows intaller,我不知道如何处理这个问题。 我有两个功能 - feature1和feature2。我希望仅在用户选择要安装的feature1时才安装feature2。所以我试过了:
<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 (&core = "3")</Condition>
<ComponentRef Id='cpp_perf' />
</Feature>
但如果用户选择功能核心,则不会安装功能core_perf。
我该如何解决这个问题?
答案 0 :(得分:14)
您需要将条件移动到组件定义中,然后使用! (功能状态)而不是&amp; (功能操作),以便在您尝试通过第二次重新运行安装来添加示例时,它可以正常工作:
<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>
答案 1 :(得分:6)
您是否考虑过将feature1作为feature2的父级?除非还要安装feature1,否则无法安装feature2。没有条件。
<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>