Wix-如何使用一个可执行文件安装多个Windows服务? [英] Wix - How to install multiple windows services with one executable?

查看:77
本文介绍了Wix-如何使用一个可执行文件安装多个Windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用相同的可执行文件安装多个Windows服务,但是WiX不喜欢两个文件标签中的相同名称属性.我尝试更改两个文件标签的名称.它可以工作,但是我希望我不必为此安装两个相同的可执行文件.有一个更好的方法吗?到目前为止,这是我的代码:

I'm trying to install multiple windows services with the same executable, but WiX doesn't like the same name attributes in the two file tags. I have tried changing the names of the two file tags. It works but I hope I don't have to install two of the same executable just for that purpose. Is there a better way to do this? Here's my code so far:

<Component Id="Service1" Guid="{SOMEGUID1}">
  <File Id='Service1' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe'  KeyPath='yes'/>
    <ServiceInstall
      Id="ServiceInstaller1"
      Type="ownProcess"
      Name="MyService1"
      DisplayName="MyService1"
      Description="Some Description"
      Start="auto" 
      Account="[SERVICEACCOUNT]"
      Password="[SERVICEPASSWORD]"
      ErrorControl="normal"
      Arguments=' "Service1"'
      Vital="yes"
      Interactive="no" />
    <ServiceControl Id="ServiceControl1" Stop="uninstall" Remove="uninstall" Name="MyService1" Wait="yes" />
</Component>

<Component Id="Service2" Guid="{SOMEGUID2}">
  <File Id='Service2' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe'  KeyPath='yes'/>
    <ServiceInstall
      Id="ServiceInstaller2"
      Type="ownProcess"
      Name="MyService2"
      DisplayName="MyService2"
      Description="Some Description"
      Start="auto" 
      Account="[SERVICEACCOUNT]"
      Password="[SERVICEPASSWORD]"
      ErrorControl="normal"
      Arguments=' "Service2"'
      Vital="yes"
      Interactive="no" />
    <ServiceControl Id="ServiceControl2" Stop="uninstall" Remove="uninstall" Name="MyService2" Wait="yes" />
</Component>

功能方面:

<Feature Id="Feature1" Title="Feature 2" Level="1" Description="...">
  <ComponentRef Id="Service1_xml"/>
  <ComponentRef Id="Service1"/>
</Feature>
<Feature Id="Feature2" Title="Feature 2" Level="1" Description="...">
  <ComponentRef Id="Service2_xml"/>
  <ComponentRef Id="Service2"/>
</Feature>

感谢您的帮助.

(PS.之所以将它们分成2个组件,是因为我可以在功能部分中将xml配置文件包含在该服务中.我的Windows Service安装程序采用命令行参数来知道要读取哪个xml文件.从并进行相应的配置)

(PS. The reason I brake them up into 2 components is so that I can include an xml config file with the service in the features section. My windows service installer takes in a command line argument to know which xml file to read from and configure accordingly)

错误输出:

ICE30:目标文件"hlo8twix.exe | ConnDriver.exe"由LFN系统上的两个不同组件安装在"[ProgramFilesFolder] \ CompanyName \ ProgramName \"中:"Service1"和"Service2".这样会中断组件引用计数.

ICE30: The target file 'hlo8twix.exe|ConnDriver.exe' is installed in '[ProgramFilesFolder]\CompanyName\ProgramName\' by two different components on an LFN system: 'Service1' and 'Service2'. This breaks component reference counting.

推荐答案

在我的一个项目中,我在一个可执行文件中有2个服务.因此,对于我的exe中的这两种服务,我的wix设置中都有以下内容.希望这会有所帮助.

In one of my projects, I have 2 services inside of one executable. So for both services in my exe, I have the following in my wix setup. Hope this helps.

  <Component Id="MyScheduler" Guid="{SOMEGUID}">
    <File Id="MySchedulerEXE" Name="MyScheduler.exe" Source="MyScheduler.exe" KeyPath="yes" />

    <ServiceInstall Id="FirstService" Type="ownProcess" Vital="yes" Name="First Service" DisplayName="First Service" Description="First Service" Start="auto" Account="NT AUTHORITY\LocalService" Interactive="no" ErrorControl="ignore" />
    <ServiceControl Id="StartFirstService" Name="First Service" Start="install" Wait="no" />
    <ServiceControl Id="StopFirstService" Name="First Service" Stop="both" Wait="yes" Remove="uninstall" />

    <ServiceInstall Id="SecondService" Type="ownProcess" Vital="yes" Name="Second Service" DisplayName="Second Service" Description="Second Service" Start="auto" Account="NT AUTHORITY\LocalService" Interactive="no" ErrorControl="ignore" />
    <ServiceControl Id="StartSecondService" Name="Second Service" Start="install" Wait="no" />
    <ServiceControl Id="StopSecondService" Name="Second Service" Stop="both" Wait="yes" Remove="uninstall" />

  </Component>

这篇关于Wix-如何使用一个可执行文件安装多个Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆