0

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

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

2 回答 2

1

您的 MajorUpgrade 未指定计划的位置。正如文档所说,默认设置在 InstallValidate 之后,并且“此计划会在安装升级产品之前完全删除已安装的产品。”因此,您的主要升级将完全卸载旧产品,删除服务,然后安装升级。

因此,您应该首先在InstallExecute 之后安排您的主要升级,因为这将表现为对现有已安装产品的更新,并且引用计数应尽量减少对您的服务的中断。这意味着您必须遵循组件规则,并增加需要替换的版本化文件的文件版本。

话虽如此,升级始终是旧产品的卸载,因此旧版本中的 ServiceControl 将运行,并且 Remove="both" 可能是问题,在升级期间删除服务。所以最初的 WiX ServiceControl 很重要。

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

为了清楚起见,您不需要在新安装中删除服务的条件。我会首先在一个更好的地方对主要升级进行排序。此外,作为新升级条件的 UPGRADINGPRODUCTCODE 绝对没有任何效果。如果通过升级卸载旧产品,则会在旧产品中设置此属性。如果你想使用这个属性,它应该在已经安装的原始产品中,所以如果它已经交付并安装,现在修改该代码为时已晚(没有补丁等)。

更详细的 MSI 日志将显示有关正在发生的事情和顺序的更多详细信息,将字符串指定为 voicewarmup。

于 2017-11-20T19:04:12.567 回答
0

我将此添加到我的<InstallExecuteSequence>

<!-- http://stackoverflow.com/questions/15965539/how-to-only-stop-and-not-uninstall-windows-services-when-major-upgrade-in-wix don't change service config on upgrade -->
<DeleteServices>NOT UPGRADINGPRODUCTCODE</DeleteServices>            
<InstallServices>NOT WIX_UPGRADE_DETECTED</InstallServices>

似乎对我有用,但由于产品的变化,我不再使用它。您必须确保不会在版本之间更改服务的配置,因为当您更改配置时,您确实需要在升级期间卸载和安装服务。

服务只会在真正的卸载时被删除(Rob [已评论问题的回答者]指出,您不需要围绕“删除”状态进行调整,因为服务的安装/卸载状态已在组件中注明)

我们只在第一次安装时安装服务。

于 2017-11-20T16:52:49.243 回答