补丁安装程序取代以前的版本

补丁安装程序取代以前的版本

本文介绍了WiX:补丁安装程序取代以前的版本(1.0.0 -> 1.0.1、1.0.0 -> 1.0.2、1.0.1 -> 1.0.2,同样)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试提供一个简单的安装程序包 (MSI),我希望通过更新(补丁)来支持它,以取代所有以前的补丁.所以我有一个 MSI V1.0.0 和 2 个补丁 V1.0.1 和 V1.0.2.用户应该能够只安装最新的补丁,而不管系统中已经应用了哪些以前的补丁.我的项目包含 2 个功能(客户端和服务器).补丁的基础总是 RTM 包(HelloWorld 1.0.msi/HelloWorld 1.0.wixpdb).

I am trying to provide a simple installer package (MSI) which I want to support with updates (patches) that supersede all previous patches. So I have a MSI V1.0.0 and 2 patches V1.0.1 and V1.0.2. The user should be able to just install the latest patch regardless which previous patches were already applied to the system. My project contains 2 features (Client and Server). The basis of the patch so is always the RTM package (HelloWorld 1.0.msi / HelloWorld 1.0.wixpdb).

所有补丁的生成(构建)都有效,因此更新程序 1.0.0 -> 1.0.1 和 1.0.0 -> 1.0.2 可以,但是当我尝试从 1.0.1 更新到 1.0.2 时补丁失败并显示以下错误消息:Windows Installer 服务无法安装升级补丁,因为要升级的程序可能丢失,或者升级补丁可能更新了不同版本的程序.请验证要升级的程序已升级存在于您的计算机上,并且您具有正确的升级补丁.".更糟糕的是,当我在已经安装了 1.0.2 的系统上运行 1.0.1 补丁时,该补丁会用旧版本覆盖现有安装!?我完全糊涂了...

The generation (build) of all patches work, so the update procedures 1.0.0 -> 1.0.1 and 1.0.0 -> 1.0.2 do, BUT when i try to update from 1.0.1 to 1.0.2 the patch fails with the following error message: "The upgrade patch cannot be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade patch may update a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch.". Even worse, when I run the 1.0.1 patch on a system where 1.0.2 is already installed, the patch overwrites the existing installation with an older version!? I am totally confused...

我还在网上找到了几篇关于修补的博客文章,但没有任何内容适用于我的替代 szenario.

I also found several blog entries on the web about patching, but nothing that works with my supersede szenario.

wix 补丁代码 - "patch1.wxs":

wix patching code - "patch1.wxs":

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Patch
      AllowRemoval="yes"
      Manufacturer="My Company"
      MoreInfoURL="http://www.mycompany.com/"
      DisplayName="HelloWorld V1.0 Patch 1"
      Description="Patch intaller updating HelloWorld V1.0.x to V1.0.1"
      Classification="Update">

    <Media Id="32000" Cabinet="HelloWorldRTM.cab">
      <PatchBaseline Id="HelloWorldRTM">
        <Validate ProductId="yes" UpgradeCode="yes" ProductVersionOperator="LesserOrEqual" />
      </PatchBaseline>
    </Media>

    <PatchFamilyRef Id="HelloWorldPatchFamily"/>
  </Patch>

  <Fragment>
    <PatchFamily Id='HelloWorldPatchFamily' Version='1.0.1.0' Supersede='yes'>
      <PropertyRef Id="ProductVersion"/>
      <ComponentRef Id="HelloWorldServer.dll"/>
    </PatchFamily>
  </Fragment>
</Wix>

补丁 1 构建脚本 - "generate_patch1.bat":

patch 1 build script - "generate_patch1.bat":

"%WIX%\bin\torch.exe" -p -xi ".\_Distrb\HelloWorld 1.0.wixpdb" ".\_Distrb\HelloWorld 1.0.1.wixpdb" -out ".\_Build\patch1.wixmst"
"%WIX%\bin\candle.exe" -out ".\_Build\patch1.wixobj" ".\patch1.wxs"
"%WIX%\bin\light.exe" ".\_Build\patch1.wixobj" -out ".\_Build\patch1.wixmsp"
"%WIX%\bin\pyro.exe" ".\_Build\patch1.wixmsp" -out ".\_Distrb\HelloWorld 1.0 Patch1.msp" -t HelloWorldRTM ".\_Build\patch1.wixmst"

wix 补丁代码 - "patch2.wxs":

wix patching code - "patch2.wxs":

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Patch
      AllowRemoval="yes"
      Manufacturer="My Company"
      MoreInfoURL="http://www.mycompany.com/"
      DisplayName="HelloWorld V1.0 Patch 2"
      Description="Patch intaller updating HelloWorld V1.0.x to V1.0.2"
      Classification="Update">

    <Media Id="32000" Cabinet="HelloWorldRTM.cab">
      <PatchBaseline Id="HelloWorldRTM">
        <Validate ProductId="yes" UpgradeCode="yes" ProductVersionOperator="LesserOrEqual" />
      </PatchBaseline>
    </Media>

    <PatchFamilyRef Id="HelloWorldPatchFamily"/>
  </Patch>

  <Fragment>
    <PatchFamily Id='HelloWorldPatchFamily' Version='1.0.2.0' Supersede='yes'>
      <PropertyRef Id="ProductVersion"/>
      <ComponentRef Id="HelloWorldServer.dll"/>
      <ComponentRef Id="HelloWorld.exe"/>
    </PatchFamily>
  </Fragment>
</Wix>

补丁 2 构建脚本 - "generate_patch2.bat":

patch 2 build script - "generate_patch2.bat":

"%WIX%\bin\torch.exe" -p -xi ".\_Distrb\HelloWorld 1.0.wixpdb" ".\_Distrb\HelloWorld 1.0.2.wixpdb" -out ".\_Build\patch2.wixmst"
"%WIX%\bin\candle.exe" -out ".\_Build\patch2.wixobj" ".\patch2.wxs"
"%WIX%\bin\light.exe" ".\_Build\patch2.wixobj" -out ".\_Build\patch2.wixmsp"
"%WIX%\bin\pyro.exe" ".\_Build\patch2.wixmsp" -out ".\_Distrb\HelloWorld 1.0 Patch 2.msp" -t HelloWorldRTM ".\_Build\patch2.wixmst"

推荐答案

我遇到了类似的问题,并通过向补丁 wxs 添加适当的验证来解决它.试试这个...

I had a similar problem, and got it fixed by adding the appropriate validation to the patch wxs. Try this...

<Media Id="32000" Cabinet="HelloWorldRTM.cab">
  <PatchBaseline Id="HelloWorldRTM">
    <Validate ProductId="yes" UpgradeCode="yes" ProductVersion="Major" ProductVersionOperator="GreaterOrEqual" />
  </PatchBaseline>
</Media>

如果您不希望补丁在安装的修订号大于补丁的修订号时起作用,您可能需要将 ProductVersion 更改为Update"并将 ProductVersion 设置为GreaterOrEqual".

If you don't want the patch to work when the installed revision number is greater than the patch's revision number, you might want to change the ProductVersion to "Update" and set the ProductVersion to "GreaterOrEqual".

希望对你有用!

这篇关于WiX:补丁安装程序取代以前的版本(1.0.0 -> 1.0.1、1.0.0 -> 1.0.2、1.0.1 -> 1.0.2,同样)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 15:33