我如果正在安装数据库的功能,设置为1的属性:WIX的ServiceControl条件
<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,但即使条件仅在DBFLAG = 0时仍然运行cmp_SvcC。
如果我将DBFLAG的初始值更改为1,则会运行cmp_SvcC_Start。
有没有人有任何想法,为什么会发生这种情况?
你可以扩展一下吗?我是wix的新手,我不太清楚你的意思。我是否将cmp_SvcC和cmp_SvcC_Start的添加到db功能? –
knappster
WiX不支持编辑FeatureComponents表。解决方案是使用Orca手动修改生成的MSI:http://msdn.microsoft.com/en-us/library/aa370557(VS.85).aspx。另一种解决方案是找到一个设置创作工具,它允许您修改此表。 –
干杯,知道这一点后,我不得不现在开始他们的代码,因为构建过程需要自动化,并且无法继续编辑msi ... – knappster