在不卸载Windows服务的情况下进行重大升级 [英] Major Upgrade without uninstallation of Windows Service

查看:104
本文介绍了在不卸载Windows服务的情况下进行重大升级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真的很抱歉,我很多余.我已经检查了本网站本身以及其他一些网站上的许多其他帖子.如果不卸载& ;;,我将无法进行主要升级.重新安装服务.我正在更改产品代码和版本,并且UpgradeFileComponent是升级的一部分.其余所有与1.0.0中的相同.我正在做POC,因此只想做一个小的更改(不是作为补丁,而是作为主要升级).以下是我的Product.wxs.我不包括ServiceAccountDlg,Variables.wxi或en-us.wxl等其他内容的标记,因为这可能会使标记变长.谁能帮帮我吗?我已经尝试过WIX_UPGRADE_DETECTED,UPGRADINGPRODUCTCODE等,但无法使其正常工作.每次,该服务都会被卸载并重新安装.我正在通过以下方式对此进行验证.服务启动后,它将在ProgramData中创建一个日志文件,并将其每5秒追加一次.在卸载MSI的过程中,我正在删除此日志文件及其文件夹.重新安装并重新启动服务后,将再次创建日志文件.借助此工具,我可以确定在进行重大升级时始终会重新安装该服务.我只希望部署新文件,而无需重新安装服务或要卸载的任何其他组件.我从某些人那里听说,该工具集将检查已更改的文件并仅在发生更改时才重新安装它们.但这似乎并非如此.我也尝试过使用带有各种值的Schedule属性,但是没有运气.任何帮助都将非常棒.我已经尝试了这么多天了,没有任何运气.请让我知道是否需要我提供更多信息.

I am really very sorry for being redundant. I have checked a lot of other posts in this site itself and perhaps some other sites. I am not able to get Major Upgrade working without uninstalling & reinstalling of service. I am changing the Product Code and Version and the UpgradeFileComponent is the component that is part of the Upgrade. All the remaining are the same as in 1.0.0. I am doing a POC and hence would like to make only this small change (not as a patch, but as a major upgrade). Following is my Product.wxs. I am not including the markup for the other things like ServiceAccountDlg, Variables.wxi or en-us.wxl, since it may make it really long. Can anyone please help me? I have already tried WIX_UPGRADE_DETECTED, UPGRADINGPRODUCTCODE and so on, but not able to get it working. Everytime, the service is getting uninstalled and reinstalled. I am verifying this in the following way. Once the service starts, it creates a log file in ProgramData and keeps appending it to every 5 seconds. During uninstallation of the MSI, I am deleting this log file and its folder. After the service gets reinstalled and restarts, the log file gets created again. With this I am able to figure out that the service is getting reinstalled always with the major upgrade. I only want the new file to be deployed without reinstalling the service or any other component being uninstalled. I have heard from some people that the toolset checks for changed files and reinstalls them only if there is a change. But this doesn't seem to be the case. I have tried using the Schedule attribute with various values also, but no luck. Any help will be really great. I have been trying this for so many days without any luck. Please let me know if any more info is required from me.

<?xml version="1.0" encoding="UTF-8"?>
<?include Variables.wxi ?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
  <Product Id="$(var.ProductCode)" Name="$(var.ProductName)" Language="!(loc.LANG)" Version="$(var.ProductVersion)" Manufacturer=" MyCompany" UpgradeCode="$(var.UpgradeCode)">

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Id="*" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

    <!--<Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion OnlyDetect="yes" Minimum="1.0.0" Maximum="2.0.0" IncludeMinimum="yes" IncludeMaximum="yes" Property="NEWERFOUND"   />
    </Upgrade>-->

    <InstallExecuteSequence>
      <!--<RemoveExistingProducts After="InstallExecute" />
      <DeleteServices>NOT UPGRADINGPRODUCTCODE</DeleteServices>-->
      <!--<InstallServices>NOT UPGRADINGPRODUCTCODE,NOT WIX_UPGRADE_DETECTED</InstallServices>-->
      <DeleteServices>NOT UPGRADINGPRODUCTCODE</DeleteServices>
    </InstallExecuteSequence>

    <Condition Message='This application only runs on Windows 7 or higher OS versions.'>
      <![CDATA[Installed OR (VersionNT64 >= 601)]]>
    </Condition>

    <MediaTemplate />

    <Property Id="MSIFASTINSTALL" Value="1"/>
    <Property Id="MsiLogging" Value="v" />
    <Property Id="MSIENFORCEUPGRADECOMPONENTRULES" Value="1" />
    <Property Id="INSTALLDIR">
      <RegistrySearch Id='MyCompanyMSISampleRegistry' Type='raw' Root='HKLM' Key='SOFTWARE\MyCompany\CustomApp' Name='INSTALLDIR' Win64='yes' />
    </Property>

    <WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
    <Feature Id='Complete' Title='Foobar 1.0' Description='The complete package.'
    Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR' AllowAdvertise='no' InstallDefault='local' Absent='disallow'>

      <Feature Id="FileFeature" Title="File Feature" Level="1" AllowAdvertise='no' InstallDefault='local' Absent='disallow' Display='expand'>
        <ComponentRef Id="FileComponent"/>
        <ComponentRef Id="UpgradeFileComponent"/>
      </Feature>
      <Feature Id="ServiceFeature" Title="Service Feature" Level="1" AllowAdvertise='no' InstallDefault='local' Absent='disallow' Display='expand'>
        <ComponentRef Id="ServiceComponent"/>
        <ComponentRef Id="deleteFolder"/>
      </Feature>
      <Feature Id="RegistryFeature" Title="Registry Feature" Level="1" AllowAdvertise='no' InstallDefault='local' Absent='disallow' Display='expand'>
        <ComponentRef Id="RegistryComponent"/>
      </Feature>           
      <Feature Id='Documentation' Title='Description' Description='The instruction manual.' Level='2' AllowAdvertise='no' InstallDefault='followParent' Absent='disallow'>
        <ComponentRef Id='Manual' />
      </Feature>

    </Feature>
    <!--<UIRef Id="WixUI_Mondo"/>
    <UIRef Id="WixUI_ErrorProgressText" />-->

    <UI Id="MyWixUI_Mondo">
      <UIRef Id="WixUI_Mondo" />

      <DialogRef Id="ServiceAccountDlg" />

      <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="ServiceAccountDlg" Order="2">LicenseAccepted = "1"</Publish>
      <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="ServiceAccountDlg">1</Publish>
    </UI>
    <UIRef Id="WixUI_ErrorProgressText" />

    <Icon Id="MyCompanyBanner.ico" SourceFile="Binary\MyCompanyBanner.ico" />

  </Product>

  <Fragment>
    <Component Id='Manual' Guid='7470A2CD-B07C-4AB4-9152-8C6AA53FA0F7' Directory='INSTALLDIR'>
      <File Id='Manual' Name='Manual.pdf' DiskId='1' Source='1.0.0\Manual.pdf' KeyPath='yes'>
        <Shortcut Id="startmenuManual" Directory="DesktopFolder" Name="Instruction Manual" Advertise="yes" />
      </File>
    </Component>
  </Fragment>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLDIR" Name="$(var.InstallFolderName)" />
      </Directory>
      <Directory Id="DesktopFolder" Name="Desktop" />
      <Directory Id="CommonAppDataFolder">
        <Directory Id="MyCompanyTestInstallerLogs" Name="MyCompanyTestInstallerLogs">
          <Component Id="deleteFolder" Guid="323549D2-90B7-4D5D-8A36-EEA0ACCCC35E">
            <RemoveFile Id="deleteServiceFile" Name="MyCompanyTestWinSvcLog.txt" On="both" Directory="MyCompanyTestInstallerLogs"/>
            <RemoveFolder Directory="MyCompanyTestInstallerLogs" Id="MyCompanyTestInstallerLogs" On="both"/>
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <Component Id="FileComponent" Directory="INSTALLDIR" Guid="F143BE3C-48D6-4138-B4E6-5CF44773CBA5" >      
      <File Id="SampleTextFile.txt" Name="Sample.txt" Source="$(var.Version)\Sample.txt" KeyPath="yes">
        <Shortcut Id="startmenuSampleText" Directory="DesktopFolder" Name="MyCompany MSI Sample" WorkingDirectory='INSTALLDIR' Icon='MyCompanyBanner.ico' Advertise='yes' />
      </File>
    </Component>
  </Fragment>

  <Fragment>
    <Component Id="UpgradeFileComponent" Directory="INSTALLDIR" Guid="4582597C-2CE0-451E-8B89-83BA4ABCE464">    
      <File Id="SampleXMLFile.xml" Name="Sample.xml" Source="$(var.Version)\Sample.xml" KeyPath="yes" />
    </Component>
  </Fragment>

  <Fragment>
    <Component Id='ServiceComponent' Directory="INSTALLDIR" Guid="AEA0E53F-3D70-4010-8592-9A01FE49344D">
      <util:User Domain="[DOMAIN]" Id="svcUser" Name="[USER_NAME]" Password="[PASSWORD]" LogonAsService="yes" CreateUser="no"/>
      <File Id='MyCompanyTestWinSvc' Name='MyCompanyTestWinSvc.exe' Source='Binary\MyCompanyTestWinSvc.exe' KeyPath='yes' />
      <ServiceInstall Id="installMyCompanyTestWinSvc" Name="MyCompanyTestWinSvc" DisplayName="MyCompany Install Test Windows Service" Start="auto" ErrorControl="normal" Type="ownProcess" Account="[DOMAIN]\[USER_NAME]" Password="[PASSWORD]" />
      <ServiceControl Id="sc_MyCompanyTestWinSvc" Name="MyCompanyTestWinSvc" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
      <ServiceControl Id="stopAndStartIIS" Name="IISADMIN" Start="uninstall" Stop="install" Wait="yes" />
      <ServiceControl Id="stopAndStartSQL" Name="MSSQLSERVER" Start="uninstall" Stop="install" Wait="yes" />
    </Component>
  </Fragment>

  <Fragment>
    <Component Id="RegistryComponent" Directory="INSTALLDIR" Guid="8D8D93A4-09F5-4511-B291-720A7BC70529">
      <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
    </Component>
  </Fragment>

</Wix>

推荐答案

您的MajorUpgrade没有指定计划时间.就像文档所说的那样,默认值是在InstallValidate之后,并且此调度将在安装升级产品之前完全删除已安装的产品."因此,您的主要升级将完全卸载旧产品,删除服务,然后安装升级.

Your MajorUpgrade does not specify where it is scheduled. As the docs say, the default is after InstallValidate and "This scheduling removes the installed product entirely before installing the upgrade product. " So your major upgrade will uninstall the older product completely, deleting the service, and then install your upgrade.

因此,您应该先在InstallExecute之后安排主要升级,因为这将像对现有已安装产品的更新一样进行操作,并且引用计数应将对服务的中断降到最低.这意味着您必须遵循组件规则,并增加需要替换的版本化文件的文件版本.

So you should start by having your major upgrade scheduled afterInstallExecute, because this will behave like an update on top of the existing installed product and the reference counting should minimize disruption to your service. This means that you must follow component rules, and increment the file versions of versioned files that need replacing.

话虽如此,升级始终是对较旧产品的卸载,因此该较旧版本中的ServiceControl将运行,而Remove ="both"可能是问题所在,在升级过程中删除了该服务.因此,原始的WiX ServiceControl很重要.

Having said that, an upgrade is always an uninstall of the older product, so the ServiceControl in that older version will run, and Remove="both" might be the problem, deleting the service during the upgrade. So the original WiX ServiceControl matters.

此外,如果未遵循组件规则,则InstallValidate之后的升级将正常进行,因为它将卸载所有内容,然后安装新产品.但是,如果InstallInstallExecute之后的升级未遵循组件规则,则可能会卸载服务组件(由于组件ID不同),并且不遵循规则可能会产生其他影响.

Also, if the component rules haven't been followed an upgrade afterInstallValidate will work fine because it uninstalls everything then installs the new product. But if the component rules have not been followed in an upgrade afterInstallExecute the service component may be getting uninstalled (because of differing component ids), and there may well be other effects of not following the rules.

为了明确起见,在新安装中不需要删除服务的条件.我将从在更好的地方对主要升级进行排序开始.另外,在新升级中将UPGRADINGPRODUCTCODE作为条件绝对没有任何效果.如果要通过升级将其卸载,则在较旧的产品中设置此属性.如果要使用此属性,则它应该位于已经安装的原始产品中,因此,如果已发货并安装了该属性,现在就更改该代码为时已晚(没有补丁等).

And to make it clear, you do not need a condition on delete services in your new install. I would start just by sequencing the major upgrade in a better place. Also, UPGRADINGPRODUCTCODE as a condition in your new upgrade has absolutely no effect. This property is set in the older product if it is being uninstalled with an upgrade. If you want to use this property it should be in the original product that is already installed, so if it's shipped and installed it is too late to alter that code now (without a patch and so on).

更详细的MSI日志将显示有关正在发生的事情的详细信息,并以什么顺序将字符串指定为voicewarmup.

A more verbose MSI log would show more detail about what is happening and in what order, specify the string as voicewarmup.

这篇关于在不卸载Windows服务的情况下进行重大升级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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