Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用WiX设置服务的恢复选项?_Wix_Wix3.5_Wix3.6 - Fatal编程技术网

如何使用WiX设置服务的恢复选项?

如何使用WiX设置服务的恢复选项?,wix,wix3.5,wix3.6,Wix,Wix3.5,Wix3.6,我有以下.wxs文件: <?xml version="1.0" encoding="UTF-8"?> <?define ProductVersion="x.x.x.x" ?> <?define UpgradeCode="{**MYGUID**}" ?> <?define Manufacturer="My Company" ?> <?define ProductName="My Product" ?> <?define SkuNam

我有以下.wxs文件:

<?xml version="1.0" encoding="UTF-8"?>
<?define ProductVersion="x.x.x.x" ?>
<?define UpgradeCode="{**MYGUID**}" ?>
<?define Manufacturer="My Company" ?>
<?define ProductName="My Product" ?>
<?define SkuName="MyProduct" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*"
             Name="$(var.ProductName)"
             Language="1033"
             Version="$(var.ProductVersion)"
             Manufacturer="$(var.Manufacturer)"
             UpgradeCode="$(var.UpgradeCode)">
        <Package InstallerVersion="301"
                 Compressed="yes"
                 InstallPrivileges="elevated"
                 InstallScope="perMachine"
                 Platform="x86" />
        <Media Id="1"
               Cabinet="$(var.SkuName).cab"
               EmbedCab="yes" />
        <Directory Id="TARGETDIR"
                   Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="ManufacturereDirectory"
                           Name="$(var.Manufacturer)">
                    <Directory Id="ProductDirectory"
                               Name="$(var.ProductName)" />
                </Directory>
            </Directory>
        </Directory>
        <ComponentGroup Id="MainComponentGroup">
            <Component Directory="ProductDirectory">
                <File Name="$(var.MyProject.TargetFileName)"
                      Source="$(var.MyProject.TargetPath)"
                      KeyPath="yes"
                      Vital="yes" />
                <ServiceInstall Id="SeviceInstall"
                                Name="$(var.ProductName)"
                                DisplayName="$(var.ProductName)"
                                Type="ownProcess"
                                Interactive="no"
                                Start="auto"
                                Vital="yes"
                                ErrorControl="normal"
                                Account="LOCALSYSTEM">
                </ServiceInstall>
                <ServiceControl Id="ServiceControl_Start"
                                Name="$(var.ProductName)"
                                Start="install"
                                Wait="no" />
                <ServiceControl Id="ServiceControl_Stop"
                                Name="$(var.ProductName)"
                                Stop="both"
                                Remove="uninstall"
                                Wait="yes" />
            </Component>
        </ComponentGroup>
        <Feature Id="MainFeature"
                 Level="1">
            <ComponentGroupRef Id="MainComponentGroup" />
        </Feature>
        <Upgrade Id="$(var.UpgradeCode)">
            <UpgradeVersion Property="UPGRADEFOUND"
                            Minimum="0.0.0.1" IncludeMinimum="yes"
                            Maximum="$(var.ProductVersion)" IncludeMaximum="yes"
                            OnlyDetect="no"
                            IgnoreRemoveFailure="yes"
                            MigrateFeatures="yes"/>
        </Upgrade>
        <CustomAction Id="ServiceRestarter"
                      Directory="ProductDirectory"
                      ExeCommand="&quot;[SystemFolder]sc.exe&quot; failure &quot;$(var.ProductName)&quot; reset= 60 actions= restart/0"
                      Impersonate="no" />
        <InstallExecuteSequence>
            <InstallExecute Before="RemoveExistingProducts" />
            <RemoveExistingProducts Before="InstallFinalize" />
            <Custom Action="ServiceRestarter" After="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
        </InstallExecuteSequence>
    </Product>
</Wix>
这不起作用,因为如果使用安装程序<5.0,则不起作用,即使使用InstallerVersion=500,我得到的唯一结果是错误:

服务“我的产品”无法配置我的产品。这可能 软件包或您的权限可能有问题。确认您 有足够的权限配置系统服务

是的。。。我也尝试过InstallPrivilges=提升-但是。。。真正的问题是Action=restartService根据

所以。。。使用CustomAction是一种选择还是一种选择

我有以下日志输出

MSI s 34:28[13:56:46:914]:注意:1:1722 2:ServiceRestarter 3:C:\Program Files x86\My Company\My Product\4:C:\Windows\SysWOW64\sc.exe故障My Product reset=60操作=重新启动/0 MSI s 34:28[13:56:46:914]:注:1:22052:3:错误 MSI s 34:28[13:56:46:914]:注意:1:22282:3:Error 4:SELECT Message FROM Error=1722 MSI c 2C:0C[13:56:46:914]:已创建字体。字符集:Req=0,Ret=0,字体:Req=MS-Shell-Dlg,Ret=MS-Shell-Dlg

错误1722。此Windows Installer软件包有问题。作为安装程序一部分运行的程序未按预期完成。请与您的支持人员或软件包供应商联系。Action ServiceRestarter,位置:C:\Program Files x86\My Company\My Product\,命令:C:\Windows\SysWOW64\sc.exe failure My Product reset=60 actions=restart/0 MSI s 34:28[13:56:48:849]:注:1:2205 2:3:错误 MSI s 34:28[13:56:48:849]:注意:1:22282:3:Error 4:SELECT Message FROM Error=1709 MSI s 34:28[13:56:48:849]:产品:我的产品-错误1722。此Windows Installer软件包有问题。作为安装程序一部分运行的程序未按预期完成。请与您的支持人员或软件包供应商联系。Action ServiceRestarter,位置:C:\Program Files x86\My Company\My Product\,命令:C:\Windows\SysWOW64\sc.exe failure My Product reset=60 actions=restart/0

操作于13:56:48结束:ServiceRestarter。返回值3。 操作于13:56:48结束:安装。返回值3

有人能帮我吗

编辑

我使用了旧的ServiceConfig扩展:

<util:ServiceConfig xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
                    FirstFailureActionType="restart"
                    SecondFailureActionType="restart"
                    ThirdFailureActionType="restart"
                    ResetPeriodInDays="1"
                    RestartServiceDelayInSeconds="20" />
这给了我以下生成错误:

错误CNDL0200:ServiceInstall元素包含未处理的 扩展元素“util:ServiceConfig”。请确保 中元素的扩展 名称空间已被删除 提供

我知道我可以通过命令行使用-extwixutileextension来解决这个错误,但是我想使用Visual Studio来构建。。。那么如何调整build命令呢


唯一的机会是在我的项目中添加对WixUtilExtension.dll的引用。

我可以看到您只尝试了MSI 5.0附带的ServiceConfig元素。然而,有一个,它已经存在了很长一段时间,似乎它的工作

元素包含3个您想要使用的参数:FirstFailureActionType、SecondFailureActionType和ThirdFailureActionType,它们都接受相同的值枚举—无、重新启动、重新启动和运行命令


试一试,如果可行的话,它比自定义操作要好得多。

对于WIX V 4.0,使用VS2015构建,以下功能有效:

1:确保WIX项目引用了WixUtilExtension.dll程序集

2:将ns添加到根Wix元素。请注意,这是适用于WIX 4.0的正确NS,与以前的版本不同

<Wix
  xmlns="http://wixtoolset.org/schemas/v4/wxs"
  xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
  >
3:确保ServiceConfig元素以正确的命名空间引用作为前缀

<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>

在Visual Studio中,为了避免在CLI中使用-ext,可以执行以下操作:

当然,您可以添加一个资源:

然后,在解决方案资源管理器->引用->添加。。 WixUtilExtension.dll

在那之后,一切都像一个符咒。 wix 3.10


当然,如果您确实使用了utils中的第二个ServiceConfig。就像我想的那样,但是没有让它在3.6上运行。你能给我提供一个有效的演示代码吗?只需添加xmlns:util=http://schemas.microsoft.com/wix/UtilExtension 噢,你自己已经猜出来了-太棒了对于那些使用VisualStudio的人,请确保参考WixUtilExtension。dll@Narkha就像我在问题的最后一句话中说的那样@david.barkhuizen事实上,有一个可用:@david.barkhuizen我的问题特别针对3.5/3.6,所以引入的是错误的-这就是为什么您的编辑被拒绝的原因,否则我会恢复itutil:ServiceConfig也适用于WIX版本3.10.0.1503,使用xmlns:util=definition和.dll引用@JaredDykstra的答案对我不起作用。但这给了我一个方向。我发现并尝试了这个:而且有效。我的WIX版本是3.10.0.2103。请记住,RestartServiceDelayInSeconds以秒为单位,但Windows UI显示分钟,因此如果在此参数中设置30秒,当通过Windows UI查看时,您将看到
他的参数设置为0分钟。感谢您的输入,但其他评论和回答中已经建议了该方法:
<Wix
  xmlns="http://wixtoolset.org/schemas/v4/wxs"
  xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
  >
<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>