patching using purely WIX

◇◆丶佛笑我妖孽 提交于 2019-12-03 16:33:48

Hitesh,

For me heat creates a component group like this:

<Fragment>
    <ComponentGroup Id="MyFiles">
        <ComponentRef Id="cmp2AA1A30564C621322ECB3CDD70B1C03C" />
        <ComponentRef Id="cmp788C978F16E473D4FD85720B5B75C207" />
    </ComponentGroup>
</Fragment>

heat command:

"%WIX%\bin\heat.exe" dir slndir\bin\Release -cg MyFiles -gg -scom -sreg -sfrag -srd -dr INSTALLDIR -out ..\Wix\MyFiles.wxs -var var.BinOutputPath -nologo -v -ke  -t wixtransform.xsl

And in patch.wxs:

<Fragment>    
    <PatchFamily Id='ProductPatchFamily' Version='1.3.0.0' Supersede='yes'>
        <ComponentRef Id="cmp2AA1A30564C621322ECB3CDD70B1C03C" />
        <ComponentRef Id="cmp788C978F16E473D4FD85720B5B75C207" />
    </PatchFamily>
</Fragment>

Take care: there is no ProductCode attribute in PatchFamily tag

I faced the same issue, the fix for this error is to add the GUID to the component and it should remain same for both the versions of msi.

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

    <Feature Id="ProductFeature" Title="WixPatch" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="WixPatch" />
        </Directory>
    </Directory>
</Fragment>

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER" >
         <Component Id="File1" **Guid="3A64BE7A-BBEC-40AD-8319-45C602734146"**>
     <File Source="D:\V2\File1.txt" Name="File1" KeyPath="yes" DiskId="1" Id="F1"/>
         </Component>

</ComponentGroup>
</Fragment>

I would also like to mention that PatchFamily elements are optional when building a patch, and are intended to allow fine grained control over exactly what will get patched. In most cases I find that I want to include all differences between 2 versions of an MSI when building a patch, in which case I omit the PatchFamily altogether. In your case, the resulting patch WXS would look like the following:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Patch 
        AllowRemoval="yes"
        Manufacturer="sample llc" 
        MoreInfoURL="sample.com"
        DisplayName="Env Patch" 
        Description="Env Specfic Patch" 
        Classification="Update"
    >
        <Media Id="5000" Cabinet="RTM.cab">
            <PatchBaseline Id="RTM" />
        </Media>
    </Patch>
</Wix>

I hope this answer helps anyone with a similar question, that is not wanting to manually construct patch families, not wanting to manually includeComponentRef every time they need to build a patch.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!