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

Can I add a ServiceInstall component in a WiX installer that references a FileId in another component

我有一个安装程序,它使用 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>            

ServiceInstall要求安装的服务是组件的KeyPath,所以不能让服务成为另一个组件中的文件。

您可以创建两个相互排斥的单独组件,一个仅包含文件,另一个将文件作为服务安装,然后选择所需的组件。你不应该为两个互斥的组件得到一个错误,这让我感到惊讶。