1

Good time,

I'm trying to create the uninstallable patch (msp file) which should contain the newly added files. The file is added in following maner:

<Directory Id="Some Dir">
  <Directory Id="MYDIR" Name="Some Name">
    <Component Id="Some Component" Guid="{GUID}" KeyPath="yes">
          <File Id="README.txt" Name="README.txt" Source="to_install\README.txt" KeyPath="no"/>
          <File Id="default.cfg" Name="default.cfg" Source="to_install\default.cfg" KeyPath="no"/>
          ... // some more files
    </Component>
  ...
...

I've also tried using the DirectoryRef but got the same results.

The "MYDIR" directory is used in other places also and several other files are already installed there, but the patch is adding new files, and the installation log shows that the CreateDirectory table becomes modified and the uninstallation for patch becomes disabled.

What is a correct way to do it using WiX?

Mikhail Churbanov
  • 4,436
  • 1
  • 28
  • 36

2 Answers2

3

KeyPath : This value points to a file or folder belonging to the component that the installer uses to detect the component. It is creating entry in CreateFolder of MSI because of KeyPath is provide at component level that is taking installation folder as its key so your patch become not uninstallable.

Provide KeyPath at one of the file of component that is the most important for that component. So it does not make entry into CreatFolder table of MSI and your patch become uninstallable.

  • Great. This was really useful. But, this is not working for SqlScript. When I add a new Component with an SqlScript element in the new msi and then build the Patch and apply it, the Uninstall option disappears. Can anyone please help? – Ven Jun 11 '18 at 05:50
2

Whether a patch is uninstallable isn't really related to a piece of WiX source like that. One thing you definitely need for an uninstallable patch is a PatchMetadata table that says that the patch is uninstallable, as here:

http://wixtoolset.org/documentation/manual/v3/patching/patch_building.html

or here, see PatchMetadata table if you use a PCP file, AllowRemoval:

https://msdn.microsoft.com/en-us/library/aa370344(v=vs.85).aspx

So there are some things you need to do during patch creation to make the patch uninstallable that are nothing to do with your WiX source. It's not clear from your question how you are creating the patch correctly.

Even if you get the patch generation working, there are some rules that must be followed, described here:

https://msdn.microsoft.com/en-us/library/aa367850(v=vs.85).aspx

where it says (for example) that you can't change the component ids of any existing installed items. Create a verbose log when installing the patch and look for messages like SELMGR and entries saying removl of components is not supported, and if that has happened it means the patch will not apply correctly.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • I haven't posted anything regarding my patch metadata as it seems to be correct as I have several files updated and it works fine if I remove the code I posted in question - patch updates my files and IS uninstallable, but only if I add new files (using the lines I've posted) - I've recieve the uninstall disabled warning - about CreateDirectory table in installation log (that is also described in question). I've already read the links you provided and it is said I CAN add new files, but I haven't found any info how to add them using WiX and still have UNISTALLABLE patch. – Mikhail Churbanov Apr 21 '15 at 08:15
  • I've also read WiX official documentation about the WiX patching and File element is not specified as element that makes patch unistallable, however - or I'm using it incorrectly, or it's a WiX issue? That whats I want to understand. – Mikhail Churbanov Apr 21 '15 at 08:17
  • Crate that verbose log. Nobody can tell from WiX source if you are breaking component rules that causes the patch to fail by going into advertised mode. Look for the entries I mentioned. – PhilDW Apr 21 '15 at 17:32