Jon*_*len 31 .net windows-installer windows-services
目前,我必须在安装新版本之前卸载旧版本的服务.我很确定这与它在提供新服务条目之前不够智能更新或删除旧服务条目有关.
有没有办法让安装程序跳过注册服务(如果它已经存在)?(我可以假设安装文件夹和服务名称在版本之间不会改变.)
另外,有没有办法在卸载时自动停止服务?
我正在使用MSI包和Visual Studio安装项目.
Fer*_*cio 17
我用WiX做了这个,它使用ServiceInstall和SeviceControl命令生成.MSI文件:
<Component Id='c_WSService' Guid='*'>
<File Id='f_WSService' Name='WSService.exe' Vital='yes' Source='..\wssvr\release\wsservice.exe' KeyPath="yes" />
<ServiceInstall Id='WSService.exe' Name='WSService' DisplayName='[product name]' Type='ownProcess'
Interactive='no' Start='auto' Vital='yes' ErrorControl='normal'
Description='Provides local and remote access to [product name] search facilities.' />
<ServiceControl Id='WSService.exe' Name='WSService' Start='install' Stop='both' Remove='uninstall' Wait='yes' />
</Component>
Run Code Online (Sandbox Code Playgroud)
这将停止服务,安装新版本并重新启动服务.
我不使用Visual Studio安装项目,所以我可能错了,但它似乎不支持作为Windows Installer标准功能的ServiceInstall和ServiceControl表.这两个表专门用于安装和更新服务....
Wix支持它(参见此示例),也许您可以创建合并模块,并在项目中使用它.
否则这可能会有所帮助:使用Visual Studio安装服务(Phil Wilson)
从命令行使用sc工具来停止和启动服务:
sc stop {name of your service}
sc start {name of your service}
Run Code Online (Sandbox Code Playgroud)
停止服务后,更新相应的文件,然后再次启动该服务.您也应该可以从安装程序中执行此操作.如果您使用Wix作为安装程序,请查看ServiceControl元素.
归档时间: |
|
查看次数: |
18525 次 |
最近记录: |