Tuesday 29 June 2010

WiX Reg File Heat Extension

WiX v2 had the tallow tool which was able to harvest a WiX fragment from a file exported from the registry (reg file). WiX v3’s replacement for this tool, Heat, lost this functionality. The code presented here adds this back as an extension to Heat. It also gives an example of how to write a custom heat extension.

You can download v0.90 of the extension from here and the source here. The extension has been built against the WiX v3.0 assemblies but works with Heat from both v3.0 and v3.5.

Using the extension

To create a basic fragment run:
        heat regfile filename.reg –ext Wix.RegFileHeatExtension.dll –out regfile.wxs

To create a more useful fragment run:
        heat regfile filename.reg –ext Wix.RegFileHeatExtension.dll –out regfile.wxs -gg -g1 -indent 2 -cg compGroup
This creates a fragment that can be referenced via the “compGroup” ComponentGroupRef/@Id element. It will also have automatically generated guids, for more information on the command line see the Heat documentation.

It should be noted that due to limitations in Windows Installer the following registry keys are not harvested by this extension:

  • REG_NONE(0), REG_LINK(6), REG_RESOURCE_LIST(8), REG_FULL_RESOURCE_DESCRIPTOR(9), REG_RESOURCE_REQUIREMENTS_LIST(a), REG_QWORD(b).
  • These will all start hex(n) in the reg file where “n” is the number/letter in brackets above.

I am hoping to get this functionality added to the WiX v3.5 core Heat command.

I hope you find this useful, if you find any problems with harvesting registry files please let me know.

Edit 04/08/10: Update to support WiX 3.0 properly.

Edit 16/12/10: This feature is now built in to WiX 3.5, see help file for details.

17 comments:

Anonymous said...

Perfect!

vm said...

Does not work for me, run it as in your example:

Microsoft (R) Windows Installer Xml Toolset Harvester version 3.0.5419.0
Copyright (C) Microsoft Corporation. All rights reserved.

heat.exe : error HEAT0001 : Method not found: 'Microsoft.Tools.WindowsInstallerX
ml.Extensions.UtilErrorEventArgs Microsoft.Tools.WindowsInstallerXml.Extensions.
UtilErrors.FileNotFound(System.String)'.

Exception Type: System.MissingMethodException

Stack Trace:
at RegFileHeatExtension.RegFileHarvester.HarvestRegFile(String path)
at RegFileHeatExtension.RegFileHarvester.Harvest(String argument)
at Microsoft.Tools.WindowsInstallerXml.Harvester.Harvest(String argument)
at Microsoft.Tools.WindowsInstallerXml.Tools.Heat.Run(String[] args)


sample regfile is:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\PDFlib]

[HKEY_LOCAL_MACHINE\SOFTWARE\PDFlib\PDFlib]

[HKEY_LOCAL_MACHINE\SOFTWARE\PDFlib\PDFlib\7.0.2]
"license"="000000-11111-222-AAA-BBBBB"
"SearchPath"="C:\uran\M5\Output\Debug"

Neil Sleightholm said...

Is Wix.RegFileHeatExtension.dll in the same folder as Heat or have you tried a fully qualified path to it?

vm said...

I've put two my reg files (ZXM51.reg and pdflib.reg) into WiX bin directory. The I ran heat for both of them. Surprizingly, even error messages are different.

C:\Program Files (x86)\Windows Installer XML v3\bin>heat regfile ZXM51.reg -ex
t Wix.RegFileHeatExtension.dll -out ntmReg3.wxs
Microsoft (R) Windows Installer Xml Toolset Harvester version 3.0.5419.0
Copyright (C) Microsoft Corporation. All rights reserved.

heat.exe : error HEAT0001 : Method not found: 'Microsoft.Tools.WindowsInstallerX
ml.Extensions.UtilErrorEventArgs Microsoft.Tools.WindowsInstallerXml.Extensions.
UtilErrors.FileNotFound(System.String)'.

Exception Type: System.MissingMethodException

Stack Trace:
at RegFileHeatExtension.RegFileHarvester.HarvestRegFile(String path)
at RegFileHeatExtension.RegFileHarvester.Harvest(String argument)
at Microsoft.Tools.WindowsInstallerXml.Harvester.Harvest(String argument)
at Microsoft.Tools.WindowsInstallerXml.Tools.Heat.Run(String[] args)

C:\Program Files (x86)\Windows Installer XML v3\bin>heat regfile pdflib.reg -ext
Wix.RegFileHeatExtension.dll -out aaa.wxs
Microsoft (R) Windows Installer Xml Toolset Harvester version 3.0.5419.0
Copyright (C) Microsoft Corporation. All rights reserved.

heat.exe : error HEAT0321 : The harvest type was not found in the list of loaded
Heat extensions.

Neil Sleightholm said...

Where is Wix.RegFileHeatExtension.dll, I would expect that to be in the bin folder not your reg files.

vm said...

Wix.RegFileHeatExtension.dll is in WiX bin folder, of course. From error message it is not clear _which_ file is not found.

Is it something to do with my OS version: Windows 7 64-bit? Program Files path is different from 32-bit windows.

Neil Sleightholm said...

My mistake, I thought I had tested it with WiX 3.0 but I hadn't. I'll see if I can do an update today.

Neil Sleightholm said...

It should now work with WiX 3.0. Please let me know if you are still having problems.

vm said...

Now it works, thanks!

Remarks: it creates components per registry key. There is no option to suppress components at all. Tallow generated "component-free" fragment.

Neil Sleightholm said...

No I don't think that is possible and I would have ask why you would want such an option, it would break component rules.

vm said...

Well I remember that each file is recommended to be stored in its own component. But does this rule exists for registry keys too?

My layout is as follows: all files are in their own components. All registry keys are in main .exe component. Because I think without the .exe file registry keys have no sense.

Neil Sleightholm said...

Yes the component rules would apply to registry keys as well if you needed to update them.

Michael said...

Didn't work for me
C:\Program Files\Windows Installer XML v3\bin>heat regfile faADMXGenerator.reg -ext Wix.RegFileHeatExtension.dll -out fadmx.reg
Microsoft (R) Windows Installer Xml Toolset Harvester version 3.0.5217.0
Copyright (C) Microsoft Corporation. All rights reserved.

heat.exe : error HEAT0001 : No harvester extension was specified.

Exception Type: System.InvalidOperationException

Stack Trace:
at Microsoft.Tools.WindowsInstallerXml.Harvester.Harvest(String argument)
at Microsoft.Tools.WindowsInstallerXml.Tools.Heat.Run(String[] args)

using Windows 7 x86

Neil Sleightholm said...

Could I confirm you have the latest version of the code and also that Wix.RegFileHeatExtension.dll is in "C:\Program Files\Windows Installer XML v3\bin". The output file should really be a wxs file but I don't think that would matter.

Anonymous said...

Great Job Neil,
There is no other heat extension available on net working properly, and detailed as you have.
Keep it up mate!!

Trevellyon Newell said...

Neil you are a star work perfectly
(although would have worked quicker if i had closed the dos prompt first so that it picked up your new extension :D ) but worked first time thankyou

heat pump said...

Thanks Niel. It worked properly, been looking for Wix fix online and so far your was the only thing that worked for me.