How can I set recovery-options of a service with WiX?

倖福魔咒の 提交于 2019-12-03 11:27:37

I can see that you've only tried the ServiceConfig element, which came with MSI 5.0. However, there's another ServiceConfig element in UtilExtension, which has been there for a long time and it seems that the thread you mention in your question confirms that it works.

The util:ServiceConfig element contains 3 parameters you'd like to use: FirstFailureActionType, SecondFailureActionType and ThirdFailureActionType, all accepting the same enumeration of values - none, reboot, restart and runCommand.

Try it out and if it works, it is far better choice than a custom action.

For WIX V 4.0, building with VS2015, the following works:

1: Ensure that WixUtilExtension.dll assembly is referenced by WIX project.

2: Add http://wixtoolset.org/schemas/v4/wxs/util ns to root Wix element. Note that this is the correct NS for WIX 4.0 (NOT http://schemas.microsoft.com/wix/UtilExtension as for previous versions).

<Wix
  xmlns="http://wixtoolset.org/schemas/v4/wxs"
  xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
  >

3: Ensure that ServiceConfig element is prefixed with correct namespace reference.

<ServiceInstall
      Id="MyService"
      Type="ownProcess"
      Name="MyService"
      DisplayName="MyService"
      Description="My Service"
      Start="auto"
      Account="[SERVICEACCOUNT]"
      Password="[SERVICEPASSWORD]"
      ErrorControl="normal"
    >

      <util:ServiceConfig
        FirstFailureActionType='restart'
        SecondFailureActionType='restart'
        ThirdFailureActionType='restart'            
        RestartServiceDelayInSeconds='30'
        ResetPeriodInDays='1'/>

</ServiceInstall>

In Visual Studio, to avoid using -ext in CLI you may do the following:

Of course, you add a resource: <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

then, in Solution Explorer -> References -> Add.. WixUtilExtension.dll

After that everything works like a charm. (wix 3.10)

Of course, if you do use the second ServiceConfig from utils. Like <util:ServiceConfig blablabla

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!