安装前停止服务
我编写了一个使用 Visual Studio 2010 安装项目安装的应用程序。作为安装的一部分,我的应用程序安装并启动 Windows 服务。那里没有问题。
当我发布应用程序的新版本时,安装程序会覆盖应用程序文件夹的内容。不幸的是,它无法覆盖该服务,因为它已经在运行。
如何在 MSI 开始复制文件之前停止该服务?我正在考虑一个自定义引导程序(安装程序先决条件),它不会安装,但会删除该服务。或者我可以在安装前使用 Orca 添加一个操作吗?或者你知道另一种方法吗?
I wrote an application that installs using the Visual Studio 2010 Setup Project. As part of its installation, my application installs and starts a Windows Service. No problems there.
When I release a new version of the application, the installer overwrites the contents of the application folder. Unfortunately, it cannot overwrite the service as it is already running.
How can I stop the service before the MSI starts copying files? I'm considering a custom bootstrapper (installer prerequisit) that doesn't install, but removes the service. Or can I use Orca to add an action before installation? Or do you know another way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常这是通过服务控制操作来完成的。基本上,您需要设置停止和删除标志才能卸载。
另一种方法是使用 ServiceInstaller.Uninstall 在自定义操作中停止并删除服务。
如果您想避免出现文件正在使用对话框,您可以尝试以下方法:
从安装程序类停止 Windows 服务时出现问题。事件触发得太晚了
Usually this is done through service control operations. Basically, you need the Stop and Delete flags set for uninstall.
Another approach would be to use ServiceInstaller.Uninstall in a custom action to stop and remove the service.
If you want to avoid the files in use dialog, you can try this approach:
Problem stopping Windows Service from Installer Class. Events fire too late