Wix:PatchFamily不能正确过滤变换(根本)

时间:2012-11-13 14:54:41

标签: wix windows-installer patch

首先,我使用的是WiX版本3.5.2519.0,但我也在最新的3.6版本上进行了测试,结果相同。

我很难找到PatchFamily如何只过滤掉火炬生成的差异的某些部分。按照手册中的示例(“使用纯WiX构建补丁”http://wix.sourceforge.net/manual-wix3/wix_patching.htm),我已经能够成功生成基本安装程序+补丁,其功能与宣传的一样。但是,当我尝试扩展该示例时,我遇到了一些问题。

简短版本: 我将一个新组件B添加到Product.wxs中与原始组件A相同的文件夹中,然后构建安装程序的版本1.0和版本1.1。组件A和B的文件在版本1.0和1.1之间更改。

使用手电筒,我在安装程序1.0和1.1之间生成转换。

使用pyro,我创建了msp补丁。请注意,我没有更改Patch.wxs,因此PatchFamily元素仍然只包含组件A的ComponentRef,而不包含组件B.

现在,基于此,我假设在应用补丁时会发生的事情是组件A的文件将被更新,但组件B的文件将保持不变。换句话说,那个pyro将从火炬中获取总变换,火炬包含组件A和B的变换,但是然后过滤掉在PatchFamily元素中找不到的所有变换动作,以便留下所有的变换动作。最终补丁是组件A的转换。

显然我错了,所以我真的想知道的是,如果可能的话,我可以在创建补丁时实际上从差异中过滤掉不需要的变换?


详细版本,如果您需要文件的内容和使用的命令:

Product.wxs:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="48C49ACE-90CF-4161-9C6E-9162115A54DD"
        Name="WiX Patch Example Product"
        Language="1033"
        Version="1.0.0"
        Manufacturer="Dynamo Corporation"
        UpgradeCode="48C49ACE-90CF-4161-9C6E-9162115A54DD">
        <Package Description="Installs a file that will be patched."
            Comments="This Product does not install any executables"
            InstallerVersion="200"
            Compressed="yes" />

        <Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
        <FeatureRef Id="SampleProductFeature"/>
    </Product>

    <Fragment>
        <Feature Id="SampleProductFeature" Title="Sample Product Feature" Level="1">
            <ComponentRef Id="SampleComponent" />
            <ComponentRef Id="SampleComponent2" />
        </Feature>
    </Fragment>

    <Fragment>
        <DirectoryRef Id="SampleProductFolder">
            <Component Id="SampleComponent" Guid="{C28843DA-EF08-41CC-BA75-D2B99D8A1983}" DiskId="1">
                <File Id="SampleFile" Name="Sample.txt" Source=".\$(var.Version)\Sample.txt" />
            </Component>
            <Component Id="SampleComponent2" Guid="{C28843DA-EF08-41CC-BA75-D2B99D8A1984}" DiskId="1">
                <File Id="SampleFile2" Name="Sample2.txt" Source=".\$(var.Version)\Sample2.txt" />
            </Component>
        </DirectoryRef>
    </Fragment>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Id="SampleProductFolder" Name="Patch Sample Directory">
                </Directory>
            </Directory>
        </Directory>
    </Fragment>
</Wix>

Patch.wxs:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Patch 
        AllowRemoval="yes"
        Manufacturer="Dynamo Corp" 
        MoreInfoURL="http://www.dynamocorp.com/"
        DisplayName="Sample Patch" 
        Description="Small Update Patch" 
        Classification="Update"
        >

        <Media Id="5000" Cabinet="RTM.cab">
            <PatchBaseline Id="RTM"/>
        </Media>

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

    <Fragment>    
        <PatchFamily Id='SamplePatchFamily' Version='1.0.0.0' Supersede='yes'>
            <ComponentRef Id="SampleComponent"/>
        </PatchFamily>
    </Fragment>
</Wix>

两个子文件夹,1.0和1.1,都包含具有不同(不同)内容的Sample.txt和Sample2.txt。

命令:

candle.exe -dVersion=1.0 product.wxs
light.exe product.wixobj -out 1.0\product.msi
candle.exe -dVersion=1.1 product.wxs
light.exe product.wixobj -out 1.1\product.msi
torch.exe -p -xi 1.0\product.wixpdb 1.1\product.wixpdb -out patch\diff.wixmst
candle.exe patch.wxs
light.exe patch.wixobj -out patch\patch.wixmsp
pyro.exe patch\patch.wixmsp -out patch\patch.msp -t RTM patch\diff.wixmst

编辑: 正如Bob Arnson所指出的那样,Fragment元素“成为一个不可变的原子单元,可以完全包含在产品中或从产品中排除”,因此为了单独更新文件,必须在不同的片段中定义它们。这当然很有用,因为我到目前为止将片段视为分离元素引用和元素定义的一种方法。如果任何人都应该远程感兴趣,以下将是Product.wxs的工作版本:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="48C49ACE-90CF-4161-9C6E-9162115A54DD"
        Name="WiX Patch Example Product"
        Language="1033"
        Version="1.0.0"
        Manufacturer="Dynamo Corporation"
        UpgradeCode="48C49ACE-90CF-4161-9C6E-9162115A54DD">
        <Package Description="Installs a file that will be patched."
            Comments="This Product does not install any executables"
            InstallerVersion="200"
            Compressed="yes" />

        <Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
        <FeatureRef Id="SampleProductFeature"/>
    </Product>

    <Fragment>
        <Feature Id="SampleProductFeature" Title="Sample Product Feature" Level="1">
            <ComponentRef Id="SampleComponent" />
            <ComponentRef Id="SampleComponent2" />
        </Feature>
    </Fragment>

    <Fragment>
        <DirectoryRef Id="SampleProductFolder">
            <Component Id="SampleComponent" Guid="{C28843DA-EF08-41CC-BA75-D2B99D8A1983}" DiskId="1">
                <File Id="SampleFile" Name="Sample.txt" Source=".\$(var.Version)\Sample.txt" />
            </Component>
        </DirectoryRef>
    </Fragment>

    <Fragment>
        <DirectoryRef Id="SampleProductFolder">
            <Component Id="SampleComponent2" Guid="{C28843DA-EF08-41CC-BA75-D2B99D8A1984}" DiskId="1">
                <File Id="SampleFile2" Name="Sample2.txt" Source=".\$(var.Version)\Sample2.txt" />
            </Component>
        </DirectoryRef>
    </Fragment>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Id="SampleProductFolder" Name="Patch Sample Directory">
                </Directory>
            </Directory>
        </Directory>
    </Fragment>
</Wix>

1 个答案:

答案 0 :(得分:3)

两个组件都在同一个片段中,因此它们都包含在补丁中。如果您不想这样,请将它们放在不同的片段中。