我是否可以在WiX安装程序中添加ServiceInstall组件,该组件引用另一个组件中的FileId

时间:2016-06-30 10:54:54

标签: wix windows-services installer

我有一个安装程序,它使用HEAT从不同的地方收集文件,为安装程序创建各种组件。

其中一个组件安装Windows服务的文件。 我想添加另一个安装服务本身的组件,但是如果我将EXE文件放在组件中,我会收到一个错误,即该文件将被安装两次。

有没有办法创建ServiceInstall组件,而不是添加File元素,引用另一个组件的文件ID? 我想保留安装文件但不安装服务的选项。

此外,如果我不得不将文件从其所在的组件中取出,它会为收获脚本添加各种复杂性。

目前,组件部分如下所示:

<Component Id='UtilServiceInstall' Guid='{2B244D6C-BEC3-471f-A0FB-5E3B729EBE56}'>
  <File Id='UtilityService' Name='UtilityService.exe' Source='UtilityService.exe' DiskId='1' KeyPath='yes' />
  <ServiceInstall Id="UtilService" Type="ownProcess" Name="UtilService" DisplayName="Utility Service" Description="Utility Service" Start="demand" Account="LocalSystem" ErrorControl="normal">
  <util:PermissionEx  User="Everyone" ServicePauseContinue="yes" ServiceQueryStatus="yes" ServiceStart="yes" ServiceStop="yes" ServiceUserDefinedControl="yes" />                                
  </ServiceInstall>
  <ServiceControl Id="UtilService" Start="install" Stop="both" Remove="both" Name="UtilService" Wait="no" />                                
</Component>            

1 个答案:

答案 0 :(得分:2)

ServiceInstall要求已安装的服务是组件的KeyPath,因此您无法将该服务作为另一个组件中的文件。

您可以创建两个互斥的独立组件,一个只包含文件,另一个文件作为服务安装,并选择任何需要的组件。对于两个相互排斥的组件,您不应该收到错误,这让我感到惊讶。