使用不同的GUID和Ids'以及互斥条件创建两个组件:一个用于文件和服务,另一个用于文件。类似这样的:
<Component Id="SvcComp" Guid="{YOUR-GUID}" SharedDllRefCount="yes">
<Condition> SOME_CONDITION </Condition>
<File Id="SvcFile" Name="Service.exe" Source="Service.exe" Vital="yes" />
<ServiceInstall Id="Svc" Name="Service" DisplayName="Service" Description="Service" Type="ownProcess" Start="auto" ErrorControl="normal" Vital="yes" />
<ServiceControl Id="Svc" Name="Service" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
<Component Id="ExeComp" Guid="{YYOUR-GUID}" SharedDllRefCount="yes" >
<Condition> NOT SOME_CONDITION </Condition>
<File Id="ExeFile" Name="Service.exe" Source="Service.exe" Vital="yes" />
</Component>
您将得到一个LGHT1076警告,因为组件中的条件是互斥的,所以可能会被禁止。
如果ServiceInstall/@ Start属性可以设置为[Property],那将会非常好,因此您仍然可以在不启动服务的情况下安装服务。 – Ivan 2017-01-18 10:29:32