WIX ServiceControl条件

时间:2011-06-22 10:57:08

标签: installer wix wix3.5

如果正在安装数据库功能,我有一个设置为1的属性:

<Property Id="DBFLAG" Value="0" />
<CustomAction Id="DbCheck" Return="check" Execute="immediate" Property="DBFLAG" Value="1" />
<InstallExecuteSequence>
        <Custom Action="DbCheck" After="CostFinalize"><![CDATA[&ft_db=3]]></Custom>
</InstallExecuteSequence>

在另一个功能中,我检查这个DBFLAG以查看它是0还是1,基于此我想立即开始服务:

<Component Id="cmp_Svc" Guid="99481212-F2E0-4B6E-934D-0994815C31ED">
            <File Id="FILE01" Source="$(var.Service.TargetDir)\Service.exe" KeyPath="yes" />

            <ServiceInstall Id="Svc" Name="My Service" Type="ownProcess" Account="[WIX_ACCOUNT_LOCALSYSTEM]" Description="My Service." DisplayName="My Service" ErrorControl="normal" Interactive="no" Start="auto" Vital="no" />
</Component>
<Component Id="cmp_SvcC_Start" Guid="2ED5DBC7-BD42-4D46-AB18-E82DB0E317AD">
            <Condition>DBFLAG=1</Condition>
            <ServiceControl Id="SvcC_Start" Name="My Service"  Remove="uninstall" Stop="both" Wait="yes" Start="install" />
</Component>

<Component Id="cmp_SvcC" Guid="5769A35B-FD61-45D4-8113-40FB762B79C6">
            <Condition>DBFLAG=0</Condition>
            <ServiceControl Id="SvcC" Name="My Service"  Remove="uninstall" Stop="both" Wait="yes" />
</Component>

但是,如果安装了数据库功能,它始终运行cmp_SvcC而不是cmp_SvcC_Start服务。我已经检查了日志,并且可以看到在运行cmp_SvcC和cmp_SvcC_Start之前DBFLAG设置为1但是仍然运行cmp_SvcC,即使条件仅在DBFLAG = 0时也是如此。

如果我将DBFLAG的初始值更改为1,则运行cmp_SvcC_Start。

有没有人知道为什么会这样?

2 个答案:

答案 0 :(得分:2)

这种方式不起作用。即使您通过属性间接进行,也无法使用要素操作来调整组件。

正确的方法是在影响其安装的所有功能之间共享您的组件。这是通过FeatureComponents table完成的。

答案 1 :(得分:2)

另一种方法是在StartServices自定义操作本身上有一个条件。像这样:

<InstallExecuteSequence>
<StartServices Sequence="5900">
    <![CDATA[VersionNT AND DBFLAG="1"]]>
</StartServices>
</InstallExecuteSequence>

为了弄清楚您想要使用的序列号,请使用Orca打开您的msi,查看InstallExecuteSequence表并在序列号后对表进行排序。

相关问题