WiX:修补程序安装程序取代以前的版本(1.0.0 - > 1.0.1,1.0.0 - > 1.0.2,1.0.1 - > 1.0.2,aso。)

时间:2012-03-06 12:40:48

标签: wix patch msp msi-patch

我正在尝试提供一个简单的安装程序包(MSI),我想支持更新(补丁),取代所有以前的补丁。所以我有一个MSI V1.0.0和2个补丁V1.0.1和V1.0.2。无论先前哪些补丁已应用于系统,用户都应该能够安装最新补丁。我的项目包含2个功能(客户端和服务器)。补丁的基础是RTM包(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补丁时,补丁会用旧版本覆盖现有安装!?我完全糊涂了......

我还在网上发现了一些关于修补的博客条目,但没有任何条款适用于我的上级szenario。

wix修补代码 - “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”:

"%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”:

<?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”:

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

1 个答案:

答案 0 :(得分:1)

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

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

如果您不希望修补程序在安装的修订版本号大于修补程序的修订版号时起作用,您可能希望将ProductVersion更改为“Update”并将ProductVersion设置为“GreaterOrEqual”。

我希望它适合你!