防止在 WiX 主要升级期间删除/安装服务 - 服务不会停止 [英] Prevent service removal/install during WiX major upgrade - service not stopping

查看:21
本文介绍了防止在 WiX 主要升级期间删除/安装服务 - 服务不会停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想象中的常见场景,但无法让事情完全正常工作.

I have what is I imagine a common scenario, but am having trouble getting things working completely.

场景很简单,我想对产品进行重大升级,无需更改服务设置,也无需重新启动.

The scenario is quite simple, I would like to perform a major upgrade of a product, without changing the service settings and without requiring a reboot.

  • 在正常安装时,服务应该安装并启动
  • 在卸载时,服务应该停止并被删除
  • 在升级时,应该停止(而不是删除)服务,写入新文件,然后重新启动服务

我主要通过在 DeleteServices 上使用 NOT UPGRADINGPRODUCTCODE 条件来实现这一点.但是,升级过程中不会停止服务,因此需要重新启动.

I have this mostly working by using the condition NOT UPGRADINGPRODUCTCODE on DeleteServices. However, the service is not being stopped during the upgrade and therefore a reboot is required.

升级时是否有某种方法可以停止服务、安装新文件并重新启动服务而不删除/安装服务?

Is there some way on an upgrade to stop a service, install the new files and restart the service without removing/installing the service?

推荐答案

您是否启用了 等待标志 以便 Windows 安装程序等待服务正确停止?http://msdn.microsoft.com/en-我们/图书馆/aa371634(v=vs.85).aspx.即使启用了此标志,您的服务也必须在 30 秒内停止,否则主要升级会继续进行.有一些方法可以实现你自己的延迟来给它更多的时间,但如果没有必要就不要这样做.本质上,这可能只是一个带有一些代码的自定义操作,这些代码实现了属性表中自定义属性中指定的延迟.

Have you enabled the wait flag for windows installer to wait for the service to stop correctly? http://msdn.microsoft.com/en-us/library/aa371634(v=vs.85).aspx . Even with this flag enabled, your service must stop within 30 seconds or the major upgrade proceeds. There are ways to implement your own delay to give it more time, but don't do that if it is not necessary. Essentially this could just be a custom action with some code that implements a delay as specified in a custom property in the property table.

请注意,DeleteServices 上的 NOT UPGRADINGPRODUCTCODE 可能看起来没有副作用,但可能发生的情况是重大升级不会删除计划在升级过程中卸载的服务.换句话说,您删除了一项服务,也许添加了一项新服务,而旧服务将无法正确卸载.像这样处理标准的 Windows Installer 操作不是最佳做法,而且几乎肯定会产生意想不到的副作用.在与 Windows Installer 战斗时,您将自己描绘成一个角落以便以后更新.

Note that the NOT UPGRADINGPRODUCTCODE on DeleteServices may appear to be without side effects, but what can happen is that a major upgrade will not delete a service that is scheduled for uninstall as part of the upgrade. In other words you have deleted a service, perhaps added a new one and the old one won't get uninstalled correctly. Messing with standard Windows Installer actions like this is not best practice, and will almost certainly have unexpected side effects. You paint yourself into a corner for later updates when fighting Windows Installer.

如果我是你,我宁愿将服务安装拆分到单独的 MSI 中,以防它处于不应受主安装影响的状态.然后您将 MSI 文件与引导程序链接在一起.如果您将来需要添加新服务或删除旧服务,这将非常灵活.而且它完全是普通的,不会与 Windows Installer 设计作斗争.这是从公司的角度思考的问题,当每个服务可能有非常不同的发布时间表时,问题是能够可靠地控制每个服务.如果您将安装程序作为第三方产品交付给某人,这可能不是您所希望的.

If I were you I would rather split the service install in a separate MSI in case it is in a state that is not supposed to be affected by the main install. Then you chain the MSI files together with a bootstrapper. This is very flexible if you need to add new services in the future, or remove older ones. And it is totally vanilla and doesn't fight against the Windows Installer design. This is thinking from a corporate perspective where the issue is to be able to control each service reliably when each one may have very different release schedules. It is probably not what you would prefer if you deliver an installer as a third party product to someone.

这篇关于防止在 WiX 主要升级期间删除/安装服务 - 服务不会停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆