首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用WiX (2.0)安装多文件NT服务

使用WiX (2.0)安装多文件NT服务
EN

Stack Overflow用户
提问于 2009-08-12 13:55:49
回答 1查看 1.4K关注 0票数 5

如何在WiX中安装带有一些附加文件的服务,并定义哪个文件是实际的服务EXE文件?

场景:我有一个只是一个EXE文件的服务,并使用以下代码将其作为Windows NT服务安装在WiX中:

代码语言:javascript
复制
<Component Id='InstallMyServiceComponent' Guid='{....}' DiskId='1'>
   <File Id='InstallMyServiceEXEFile' LongName='MyService.exe' 
         Name='MyServ.exe' src='MyService/bin/release/MyService.exe' KeyPath='yes'/>
   <ServiceInstall Id='InstallMyService' Name='MyService' Description='My Service'
         ErrorControl='normal' Start='auto' Type='ownProcess' Vital='yes' />
   <ServiceControl Id='UninstallMyService' Name='MyService' Remove='uninstall' 
         Wait='yes' />
</Component>
<Component Id='RunMyServiceComponent' Guid='.......'>
   <ServiceControl Id='RunMyService' Name='MyService' Start='install' 
         Stop='uninstall' Wait='no' />
</Component>

我有一个功能,可以安装和启动这项服务。

现在,我的问题是-现在我的服务增长了,单个EXE不再是单个EXE -它是多个文件、EXE、DLL和一些支持文件。

但是,我现在如何安装它??

我试着让我所有的文件都有一个组件

代码语言:javascript
复制
<Component Id="MyService" Guid="......" DiskId="1">
  <File Id="fileMyService_framework_dll" LongName="Framework.dll" 
        Name="Framewrk.DLL" src="MyService\Framework.dll" />
  <File Id="fileMyService_dal_dll" LongName="MyServiceDAL.dll" 
        Name="SrvcDAL.DLL" src="MyService\ServiceDAL.dll" />
  <File Id="fileMyService_helpers_dll" LongName="Helpers.dll" 
        Name="Helpers.DLL" src="MyService\Helpers.dll" />
  <File Id="fileMyService_exe" LongName="MyService.exe" 
        Name="MySrv.EXE" src="MyService\MyService.exe" />
</Component>

首先,我尝试将ServiceInstall和ServiceControl标记添加到此组件:

代码语言:javascript
复制
<Component Id="MyService" Guid="......" DiskId="1">
  <File Id="fileMyService_framework_dll" LongName="Framework.dll" 
        Name="Framewrk.DLL" src="MyService\Framework.dll" />
  <File Id="fileMyService_dal_dll" LongName="MyServiceDAL.dll" 
        Name="SrvcDAL.DLL" src="MyService\ServiceDAL.dll" />
  <File Id="fileMyService_helpers_dll" LongName="Helpers.dll" 
        Name="Helpers.DLL" src="MyService\Helpers.dll" />
  <File Id="fileMyService_exe" LongName="MyService.exe" 
        Name="MySrv.EXE" src="MyService\MyService.exe" />
   <ServiceInstall Id='InstallMyService' Name='MyService' 
        Description='My Service' ErrorControl='normal' Start='auto' 
        Type='ownProcess' Vital='yes' />
   <ServiceControl Id='UninstallMyService' Name='MyService' 
        Remove='uninstall' Wait='yes' />
</Component>

但是随后我的"Framework.dll“被设置为正在创建的服务的源路径......

因此,我想我应该创建第二个组件来实际安装服务,使用ServiceInstall,并且我只使用FileRef引用该服务EXE文件-但这似乎并不存在(至少在Wix2中)。

代码语言:javascript
复制
<Component Id='InstallMyServiceComponent' Guid='{....}' DiskId='1'>
   <FileRef Id='fileMyService_exe' KeyPath='yes'/>
   <ServiceInstall Id='InstallMyService' Name='MyService' 
         Description='My Service' ErrorControl='normal' Start='auto' 
         Type='ownProcess' Vital='yes' />
   <ServiceControl Id='UninstallMyService' Name='MyService' 
         Remove='uninstall' Wait='yes' />
</Component>

那么,一个可怜的WiX作者应该怎么做才能安装所有必要的文件,同时仍然让NT服务安装程序选择正确的EXE文件(而不是组件文件列表中的任意文件)?

Marc

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-08-12 20:00:28

ServiceInstall元素最终将指向ServiceInstall所在组件的"KeyPath“。默认情况下,WiX工具集会选取组件中的第一个文件或RegistryKey元素作为KeyPath。当您将文件添加到组件中时,列表顶部的.dll将成为KeyPath。

一般来说,较小的组件比较大的组件更好。因此,更好的解决方案是将DLL放在单独的组件中。然后,您可以将.exe文件元素和ServiceInstall元素保留在同一组件中。这让一切都变得非常干净。

如果您希望将“服务”组合在一起,则可以创建一个ComponentGroup元素并将ComponentRefs放入.exe和.dll组件。现在,您可以从Feature/ComponentGroupRef中引用一件事。

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1266313

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档