title: Wix: PatchFamily doesn't filter transforms properly (at all)
body: <p>first of all, I'm using WiX version 3.5.2519.0, but I've also tested this on the newest 3.6-release with the same results.</p>
  
  <p>I'm having some trouble finding out how excactly PatchFamily can filter out only certain parts of a torch-generated diff. Following the example in the manual ("Building a patch using purely WiX" <a href="http://wix.sourceforge.net/manual-wix3/wix_patching.htm" rel="nofollow">http://wix.sourceforge.net/manual-wix3/wix_patching.htm</a>), I've been able to successfully generate a basic installer + patch that works as advertised. However, when I try to expand on that example I run into some issues.</p>
  
  <p>Short version:
  I add a new component, B, to the same folder as the original component A in Product.wxs, then build version 1.0 and version 1.1 of the installer. The files of both component A and B are changed between version 1.0 and 1.1. </p>
  
  <p>Using torch, I generate the transform between installer 1.0 and 1.1.</p>
  
  <p>Using pyro, I create the msp patch. Note that I did not change Patch.wxs, so the PatchFamily element still only contains a ComponentRef to component A, and not component B.</p>
  
  <p>Now, based on this, I assumed what would happen when I applied the patch was that the file of component A would be updated, but that the file of component B would stay the same. In other words, that pyro would take the total transform from torch, which contains the transform of both component A and B, but then filter away all the transform actions that cannot be found in a PatchFamily element, so that all that is left in the final patch is the transform of component A.</p>
  
  <p>Apparently I was wrong, so all I really want to know is how, if possible, I can actually filter out unwanted transforms from a diff when creating a patch?</p>
  
  <hr>
  
  <p>Detailed version, if you want the contents of the files and the commands used:</p>
  
  <p>Product.wxs:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
      &lt;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"&gt;
          &lt;Package Description="Installs a file that will be patched."
              Comments="This Product does not install any executables"
              InstallerVersion="200"
              Compressed="yes" /&gt;
  
          &lt;Media Id="1" Cabinet="product.cab" EmbedCab="yes" /&gt;
          &lt;FeatureRef Id="SampleProductFeature"/&gt;
      &lt;/Product&gt;
  
      &lt;Fragment&gt;
          &lt;Feature Id="SampleProductFeature" Title="Sample Product Feature" Level="1"&gt;
              &lt;ComponentRef Id="SampleComponent" /&gt;
              &lt;ComponentRef Id="SampleComponent2" /&gt;
          &lt;/Feature&gt;
      &lt;/Fragment&gt;
  
      &lt;Fragment&gt;
          &lt;DirectoryRef Id="SampleProductFolder"&gt;
              &lt;Component Id="SampleComponent" Guid="{C28843DA-EF08-41CC-BA75-D2B99D8A1983}" DiskId="1"&gt;
                  &lt;File Id="SampleFile" Name="Sample.txt" Source=".\$(var.Version)\Sample.txt" /&gt;
              &lt;/Component&gt;
              &lt;Component Id="SampleComponent2" Guid="{C28843DA-EF08-41CC-BA75-D2B99D8A1984}" DiskId="1"&gt;
                  &lt;File Id="SampleFile2" Name="Sample2.txt" Source=".\$(var.Version)\Sample2.txt" /&gt;
              &lt;/Component&gt;
          &lt;/DirectoryRef&gt;
      &lt;/Fragment&gt;
  
      &lt;Fragment&gt;
          &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
              &lt;Directory Id="ProgramFilesFolder" Name="PFiles"&gt;
                  &lt;Directory Id="SampleProductFolder" Name="Patch Sample Directory"&gt;
                  &lt;/Directory&gt;
              &lt;/Directory&gt;
          &lt;/Directory&gt;
      &lt;/Fragment&gt;
  &lt;/Wix&gt;
  </code></pre>
  
  <hr>
  
  <p>Patch.wxs:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
      &lt;Patch 
          AllowRemoval="yes"
          Manufacturer="Dynamo Corp" 
          MoreInfoURL="http://www.dynamocorp.com/"
          DisplayName="Sample Patch" 
          Description="Small Update Patch" 
          Classification="Update"
          &gt;
  
          &lt;Media Id="5000" Cabinet="RTM.cab"&gt;
              &lt;PatchBaseline Id="RTM"/&gt;
          &lt;/Media&gt;
  
          &lt;PatchFamilyRef Id="SamplePatchFamily"/&gt;
      &lt;/Patch&gt;
  
      &lt;Fragment&gt;    
          &lt;PatchFamily Id='SamplePatchFamily' Version='1.0.0.0' Supersede='yes'&gt;
              &lt;ComponentRef Id="SampleComponent"/&gt;
          &lt;/PatchFamily&gt;
      &lt;/Fragment&gt;
  &lt;/Wix&gt;
  </code></pre>
  
  <hr>
  
  <p>Two subfolders, 1.0 and 1.1, both containing Sample.txt and Sample2.txt with varying (differing) contents.</p>
  
  <p>Commands:</p>
  
  <pre><code>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
  </code></pre>
  
  <hr>
  
  <p>Edit:
  As Bob Arnson was nice enough to point out, the Fragment element "becomes an immutable, atomic unit which can either be completely included or excluded from a product", so in order to update files individually they have to be defined in different fragments. This certainly was good to know, as I've so far treated fragments as just a way to separate element-references and element-definitions. In case anyone should be remotely interested, the following would be a working version of Product.wxs:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
      &lt;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"&gt;
          &lt;Package Description="Installs a file that will be patched."
              Comments="This Product does not install any executables"
              InstallerVersion="200"
              Compressed="yes" /&gt;
  
          &lt;Media Id="1" Cabinet="product.cab" EmbedCab="yes" /&gt;
          &lt;FeatureRef Id="SampleProductFeature"/&gt;
      &lt;/Product&gt;
  
      &lt;Fragment&gt;
          &lt;Feature Id="SampleProductFeature" Title="Sample Product Feature" Level="1"&gt;
              &lt;ComponentRef Id="SampleComponent" /&gt;
              &lt;ComponentRef Id="SampleComponent2" /&gt;
          &lt;/Feature&gt;
      &lt;/Fragment&gt;
  
      &lt;Fragment&gt;
          &lt;DirectoryRef Id="SampleProductFolder"&gt;
              &lt;Component Id="SampleComponent" Guid="{C28843DA-EF08-41CC-BA75-D2B99D8A1983}" DiskId="1"&gt;
                  &lt;File Id="SampleFile" Name="Sample.txt" Source=".\$(var.Version)\Sample.txt" /&gt;
              &lt;/Component&gt;
          &lt;/DirectoryRef&gt;
      &lt;/Fragment&gt;
  
      &lt;Fragment&gt;
          &lt;DirectoryRef Id="SampleProductFolder"&gt;
              &lt;Component Id="SampleComponent2" Guid="{C28843DA-EF08-41CC-BA75-D2B99D8A1984}" DiskId="1"&gt;
                  &lt;File Id="SampleFile2" Name="Sample2.txt" Source=".\$(var.Version)\Sample2.txt" /&gt;
              &lt;/Component&gt;
          &lt;/DirectoryRef&gt;
      &lt;/Fragment&gt;
  
      &lt;Fragment&gt;
          &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
              &lt;Directory Id="ProgramFilesFolder" Name="PFiles"&gt;
                  &lt;Directory Id="SampleProductFolder" Name="Patch Sample Directory"&gt;
                  &lt;/Directory&gt;
              &lt;/Directory&gt;
          &lt;/Directory&gt;
      &lt;/Fragment&gt;
  &lt;/Wix&gt;
  </code></pre>