【发布时间】:2011-06-22 10:57:07
【问题描述】:
如果正在安装数据库功能,我有一个属性设置为 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 服务。我检查了日志,可以看到 DBFLAG 在 cmp_SvcC 和 cmp_SvcC_Start 运行之前设置为 1,但 cmp_SvcC 仍然运行,即使条件仅在 DBFLAG=0 时运行。
如果我将 DBFLAG 的初始值更改为 1,那么 cmp_SvcC_Start 就会运行。
有人知道为什么会这样吗?
【问题讨论】:
标签: installation wix wix3.5