失败条件 wix [英] Failing condition wix

查看:34
本文介绍了失败条件 wix的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在以下情况下跳过安装:

I am trying to skip installations in the following cases:

  1. Windows 操作系统类型是 = 桌面操作系统
  2. 如果 HKLM\SYSTEM\CurrentControlSet\Services\MyService MYKEY= myValue
  3. 如果存在 REG HKLM\SYSTEM\CurrentControlSet\Services\MyService = DisplayName并且 HKLM\SYSTEM\CurrentControlSet\Services\MyService MYKEY 不存在

安装时一切顺利,但安装时我的功能在安装中丢失了.

while installation it went well, but while installation my feature is missing from installation.

我在放置条件时做错了什么吗?

Am I doing anything wrong in putting condition?

<Property Id="MYKEY" Secure="yes">
        <RegistrySearch Id="MyKey"
                             Root="HKLM"
                             Key="SYSTEM\CurrentControlSet\Services\MyService"
                             Name="mykey"
                             Type="raw" />
    </Property>
    <Property Id="MYSERVICE" Secure="yes">
        <RegistrySearch Id="MYSERVICE"
                        Root="HKLM"
                             Key="SYSTEM\CurrentControlSet\Services\MyService"
                             Name="DisplayName"
                             Type="raw" />
    </Property>
<Feature Id="MyFeature" Level="" Display="" Title="" Description="" AllowAdvertise="no" ConfigurableDirectory="INSTALLDIR">
   <MergeRef Id="MyFeature" Primary="yes"/>
   <Condition Level="0">((MsiNTProductType=1) OR 
   (MYKEY="MyValue") OR 
   (MYSERVICE="MyService" AND MYKEY=""))</Condition>
   </Condition>
</Feature>

推荐答案

注意:以下内容尚未经过广泛测试 - 条件因难以正确处理而臭名昭著.测试条件需要实际测试.还有几个链接:

NOTE: The below has not been tested extensively - conditions are notorious for being difficult to get right. Testing conditions requires real-world testing. A few more links:

  • Condition debugging
  • WiX launch conditions
  • Wix Tools update uses old custom actions (example of complex conditions)
  • How to add a WiX custom action that happens only on uninstall (via MSI)?

当这三个子"条件中的任何一个为真时,您想要实现什么?

When either of those three "sub"-conditions are true, what do you want to achieve?

  1. 中止设置:中止整个设置?(启动条件)
  2. 配置功能:阻止或启用特定功能的安装?(功能条件)

这种差异显然至关重要——我们必须知道才能回答.您的 WiX 源代码段当前显示用作功能条件的条件.我有一种感觉,这不是你想要的.

This difference is obviously crucial - and we must know to be able to answer. Your WiX source snippet currently shows the conditions used as feature conditions. I have a feeling this is not what you want.

LaunchConditions:为了在这些条件之一成立时中止整个设置,您可以尝试使用 LaunchCondition 条目.您可以将它们分成三个不同的条目,而不是创建一个复杂的条件,每个条目检查是否应该中止设置——每个条目都有不同的特定原因.我建议您在 WiX 源文件中的 Package 元素之后添加这些 LaunchCondition 条目:

LaunchConditions: In order to abort the whole setup if one of these conditions are true, you could try to use LaunchCondition entries. Instead of making one complicated condition, you can just split them in three different entries that each check if the setup should be aborted - each entry for a different and specific reason. I suggest you add these LaunchCondition entries after your Package element in your WiX source file:

<Condition Message="Aborting setup: Server OS required for installation.">Installed OR MsiNTProductType=1</Condition>
<Condition Message="Aborting setup: State reason for abortion.">Installed OR MYKEY="MyValue"</Condition>
<Condition Message="Aborting setup: State reason for abortion.">Installed OR (MYSERVICE="MyService" AND MYKEY="")</Condition>

这些条目将进入已编译的 MSI 文件的启动条件表.

LaunchConditions 必须始终评估为 true 才能安装/运行设置.

相应地,上述条件的Installed部分是为了确保安装后条件始终为真-因此您不会遇到安装程序不允许自身被卸载的情况或因不满足发射条件而修复.条件:Installed - 除了 fresh installmajor upgrades 外,将始终为真.

Accordingly, the Installed parts of the conditions above are there to ensure that the condition is always true after installation - so you don't get the situation that the setup will not allow itself to be uninstalled or repaired because a launch condition is not met. The condition: Installed - will always be true except for a fresh install and major upgrades.

注意:我不确定启动条件是否会在管理安装期间造成问题.我不认为他们这样做(管理安装具有自己的安装顺序).明天我会测试和验证.添加 OR ACTION=ADMIN" 应该在运行管理安装时使启动条件在任何框中为真.

NOTE: I am not sure whether launch conditions can cause trouble during administrative installations. I don't think they do (an administrative installation features its own installation sequences). I will test and verify tomorrow. Adding OR ACTION="ADMIN" should make the launch condition true on any box when administrative installation is run.

功能条件:如果您不想中止安装,而是想根据评估这些条件来控制功能安装状态,则需要使用功能条件概念,而不是启动条件概念.

Feature Conditions: If you don't want to abort the setup, but rather want to control feature installation status based on evaluating these conditions, you need to use the feature conditions concept instead of the launch condition concept.

当您在 WiX 源中将 Feature level 设置为 0 时,该功能不会显示在设置 GUI 中,而是 默认情况下也不会安装.功能条件可以更改此设置,并在条件评估为真时设置要安装的功能.

When you set the Feature level to 0 in your WiX source, the feature is not show in the setup GUI and it is not going to be installed by default either. A feature condition can change this and set the feature to install if the condition evaluates to true.

您也可以反过来,将功能级别设置为默认值(这应该安装该功能),然后使用功能条件将其功能级别设置为 0 - 如果您不想安装该功能- 当条件为真时.

You can also go the other way around and set the feature level to 1 as default (this should install the feature) and then use a feature condition to set its Feature level to 0 - if you don't want the feature installed - when the condition is true.

快速模型"下有一些进一步的细节;此处:WIX If...else 条件使用注册表.

There are some further details under "Quick Mockup" here: WIX If...else condition using registry.

在下面的 WiX 代码段中,我们设置了一个默认安装的功能(Level=1"),然后我们使用功能条件将该功能设置为如果其关联条件评估为真(这是一个多部分条件),则不安装.因此,一旦条件评估为真,我们分配功能 Level=0"(这意味着不安装功能并将其从设置 GUI 中隐藏):

In the below WiX snippet we set a feature to install by default (Level="1") and then we use a feature condition to set the feature to not install if its associated condition evaluates to true (this is a multi-part condition). So once the condition evaluates to true we assign feature Level="0" (which means do not install feature and hide it from the setup GUI):

<Feature Id="MyFeature" Level="1"> <!--Default to install feature-->

  <Condition Level="0"> <!--Do not install feature if condition is true-->
    ((MsiNTProductType=1) OR (MYKEY="MyValue") OR (MYSERVICE="MyService" AND MYKEY="") AND (NOT ACTION="ADMIN"))
  </Condition>

</Feature>

AND (NOT ACTION=ADMIN") 部分用于强制在管理安装中安装该功能.如果安装程序在管理安装模式下运行,它会有效地将其他条件从评估为真关闭 - 这将导致在管理安装期间无法安装该功能.这最后一部分我明天必须测试.

The AND (NOT ACTION="ADMIN") part is to force the feature to be installed in an administrative installation. It effectively shuts off the other conditions from evaluating to true if the setup is run in administrative install mode - which would cause the feature to not be installed during the admin install. This last part I have to test tomorrow.

UPDATE:测试表明在管理安装期间根本不会提取任何设置为 Level=0 作为默认值的功能,无论设置要安装的功能的任何功能条件如何.一世猜测暂定结论是不设置任何特征Level=0,但设置 Level=1 然后将它们设置为 Level=0评估为真的特征条件.这样的功能可能是隐藏在常规安装中,但所有功能 - 与相关文件 - 在管理员安装期间提取.条件的 AND (NOT ACTION=ADMIN") 部分似乎不需要.暂时保留上面的示例.

UPDATE: Testing indicates that any feature set to Level=0 as default will not be extracted during an administrative install at all, regardless of any feature conditions setting the feature to install. I guess the tentative conclusion is to not set any features to Level=0, but set Level=1 and then set them to Level=0 with a feature condition that evaluates to true. This way the feature may be hidden in a regular installation, but all features - with associated files - are extracted during admin installation. The AND (NOT ACTION="ADMIN") part of the condition appears to not be needed. Leaving the sample above as it is for now.


链接:


Links:

这篇关于失败条件 wix的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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