WiX-修改已安装的产品后重新启动服务 [英] WiX - Restart service after modification of the installed product

查看:231
本文介绍了WiX-修改已安装的产品后重新启动服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个MSI,该MSI安装Windows服务并添加该服务使用的一些DLL.这些DLL是可以使用安装程序添加或删除的功能.

I'm writing a MSI which installs a windows service and adds some DLLs which the service uses. Those DLLs are features which can be added or removed using the installer.

用户修改已安装的产品(例如添加新功能)后,需要重新启动Windows服务.除了调用可重启服务的自定义操作之外,在WiX 3.5中还有其他更优雅的方法吗?

After a user modifies the installed product(eq. add a new feature), windows service needs to be restarted. Is there a more elegant way of doing so in WiX 3.5 other than calling a custom action which would restart the service?

这就是我启动服务的方式.

This is how I'm starting the service.

<ServiceControl Id="StartService" Name="MyService" Start="install" Stop="both" Remove="uninstall"  Wait="yes" />

这是完整的组件代码.忽略ID.

Here's the complete component code. Disregard the ids.

<Component Id="MyService" Guid="GUID">
     <File Id="MyService"
      Source="$(var.BuildDestination)/$(var.NameSpacePrefix).MyService.exe"
      KeyPath="yes"
      >
</File>
<RemoveFile Id='AppConfigFile' On='uninstall' Name='MyService.exe.Config' />
<User xmlns="http://schemas.microsoft.com/wix/UtilExtension"
         Id="ServiceAccount"
         CreateUser="no"
         FailIfExists="no"
         RemoveOnUninstall="no"
         UpdateIfExists="yes"
         Disabled="no"
         LogonAsService="yes"
         Name="[ACCOUNT]"
         Password="[PASSWORD]" />
<ServiceInstall
          Id="MyService"
          Type="ownProcess"
          Vital="yes"
          Name="MyService"
          DisplayName="MyService"
          Description="MyService"
          Start="auto"
          Account="[ACCOUNT]"
          Password="[PASSWORD]"
          ErrorControl="ignore"
          Interactive="no">
</ServiceInstall>
<ServiceControl Id="StartService"
                Name="MyService"
                Start="install"
                Stop="both"
                Remove="both"
                Wait="yes"
                >
</ServiceControl>

推荐答案

由于服务功能(安装和启动服务的功能)的状态未更新,因此服务本身也未停止或启动. 通过将ServiceControl添加到所有单独功能的组件中,我已经解决了该问题.

As the state of the service feature(feature which installs and starts the service) wasn't updated, the service itself wasn't stopped and started too. I've solved the issue by adding ServiceControl to all components which are separate features.

<Component Id="Modules1" Guid="GUID">
<File Id="Modules.1" Source="$(var.BuildDestination)/$(var.NameSpacePrefix)Modules.1.dll" KeyPath="yes">
</File>
<ServiceControl Id="StartService1"
               Name="MyService"
               Start="install"
               Stop="both"
               Wait="yes"
                >
</ServiceControl>

这篇关于WiX-修改已安装的产品后重新启动服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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