mar*_*c_s 5 windows-services wix wix2
如何在WiX中安装带有一些附加文件的服务,并定义哪个文件是实际的服务EXE文件?
场景:我有一个只有一个EXE文件的服务,并使用以下代码在WiX中将其安装为Windows NT服务:
<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>
Run Code Online (Sandbox Code Playgroud)
我有一个功能,然后允许安装和可选地启动此服务.
现在,我的问题是 - 现在我的服务已经增长,单个EXE不再是单个EXE - 它是多个文件,EXE,DLL和一些支持文件.
但是,我该如何安装呢?
我试图让我的所有文件都有一个组件
<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>
Run Code Online (Sandbox Code Playgroud)
首先,我尝试将ServiceInstall和ServiceControl标记添加到此组件:
<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>
Run Code Online (Sandbox Code Playgroud)
但后来我的"Framework.dll"被设置为正在创建的服务的源路径........
所以我想我会创建第二个组件来实际安装服务,使用ServiceInstall,我只是使用FileRef引用该服务EXE文件 - 但这似乎不存在(至少在Wix2中).
<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>
Run Code Online (Sandbox Code Playgroud)
那么 - 什么是一个糟糕的WiX作者必须安装所有必要的文件,并仍然得到NT服务安装,以获取正确的EXE文件(不只是组件的文件列表中的任何文件)?
渣
ServiceInstall元素最终将指向ServiceInstall所在组件的"KeyPath".默认情况下,WiX工具集会选择组件中的第一个File或RegistryKey元素作为KeyPath.将文件添加到Component时,列表顶部的.dll变为KeyPath.
通常,较小的组件比较大的组件更好.因此,更好的解决方案是将DLL放在单独的组件中.然后,您可以将.exe File元素和ServiceInstall元素保留在同一个Component中.这使得它非常干净.
如果您希望将"服务"组合在一起,则可以创建ComponentGroup元素并将ComponentRefs放入.exe和.dll组件.现在您可以从Feature/ComponentGroupRef中引用一个东西.
| 归档时间: |
|
| 查看次数: |
1404 次 |
| 最近记录: |