如何在 .NET 中自动更新我的 Windows 服务?
我每周都会为我的 Windows 服务发布一些修改,而我的用户必须手动更新它。我曾考虑推出自己的自动更新组件,但我听说了 ClickOnce,它似乎只适合 Windows 窗体而不适合 Windows 服务。我的情况有类似的解决方案吗?
如果我自己开发这个功能,我应该:
- 停止服务,替换文件,启动服务吗?
或者
- 卸载并安装新版本?
对于这两个选项,我想我都需要管理员权限,这需要用户干预,所以它根本不是自动的,对吧?
I release several modifications a week for my Windows Services and my users have to update it manually. I was think in rolling my own auto-update component, but I heard of ClickOnce, which seems to suit only Windows Forms and not Windows Services. Is there any similar solution for my case?
And if I should develop this feature myself, should I:
- Stop the service, replace the files, start the service?
or
- Uninstall and Install the new version?
for both options I think I will need admin rights, which require user intervention, so it's not automatic at all, right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以让该服务只是一个外壳。每隔一段时间(一天一次?)让服务通过查询 Web 服务器来检查新版本。如果存在新版本,请让它卸载执行工作的实际程序集,下载并保存新程序集,然后再次启动。
You could have the service simply be a shell. Every so often (once a day?) have the service check for a new version by querying a web server. If a new version exists, have it unload the actual assembly which performs the work, download and save the new assembly, then kick itself off again.