"Smart cabbing" added to WiX toolset.

Last week I added a somewhat cool feature to the WiX toolset (v3-only, of course). I call the feature "smart cabbing". I didn't actually invent the feature, somebody in Visual Studio came up with the idea for VS2003's setup (I think). The idea is actually quite simple, "If you have to put the same file into the same cabinet but with different names, do not duplicate the binary content."

You might think, "Why would anyone put duplicate copies of a file in the same cabinet? That's just dumb." At first, blush it does seem kinda' lame. However, the structure of a Windows Installer package requires that a file getting installed to multiple directories must have different identifiers in the MSI database. Since the Windows Installer requires that files are stored in cabinets by the file identifier you can realistically end up with files duplicated in a cabinet.

Even then, I questioned how often does this scenario really happens? Well, the driving force for this functionality comes from Visual Studio for the .NET Framework. Peter Marcu explained to me that the .NET Framework has to install many its files into two locations: the %SystemRoot%\Microsoft.NET\Framework directory as well as the Global Assembly Cache.

If I remember correctly, Peter mentioned that removing the duplicate files saves about 10 MB. Not a bad savings. It was definitely worth the 4 or so hours I put into writing and testing the smart cabbing feature.

Now the intrepid developer might note, "Hey, doesn't the Windows Installer provide a mechanism to duplicate a file multiple times during an install?" That is correct. However, the DuplicateFiles Action does not do integrity checking on the duplicated files so repairs and patching are less robust. Also, in my tests, the duplication functionality will not copy files out of the Global Assembly Cache so the .NET Framework scenario still requires this smart cabbing feature.

Anyway, using smart cabbing in the latest builds of the WiX toolset is simple. Just build your MSI package like normal and if you end up including more than one file with exactly the same source path then light.exe will only add the content from one of the files. No new switches needed to take advantage of the feature. In fact, the only difference you'll notice is that rebuilding an MSI file with duplicate files compressed inside it will create a smaller MSI package.

FireGiant provides dedicated support for the WiX toolset. Ever wish you could get your WiX questions answered immediately with the technical detail that you find in the blog posts here? You can with FireGiant!

Send a comment

Thank you for sending your comment.