"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.

 

posted @ Friday, June 01, 2007 3:44 AM

Print

Comments on this entry:

# re: "Smart cabbing" added to WiX toolset.

Left by Heath Stewart at 6/1/2007 11:42 AM

The savings can be even greater than that, actually. From http://blogs.msdn.com/heaths/archive/2005/04/15/hacking-the-cab-for-smaller-patches.aspx, .NET 2.0 64-bit runtimes carry mostly MSIL assemblies, but because they go into Framework and Framewok64 directories they also have different File IDs and are duplicated (depending how the 64-bit MSI was created/merged). Only 8 assemblies are unique between the 32- and 64-bit frameworks.

# re: "Smart cabbing" added to WiX toolset.

Left by Christopher Painter at 6/1/2007 11:54 AM

A good technical solution, but where is the strategy? Why not just ask the MSI team to extend the core SDK to support this use case so that all setup tools vendors do it the same way?

# re: "Smart cabbing" added to WiX toolset.

Left by Rob Mensching at 6/1/2007 12:21 PM

Strategy? The strategy is to build the best Windows Installer packages possible. This is just a feature. Features are steps (tactical) towards a goal (strategy).

Ask the MSI team? Two reasons. 1. I have a lot of "asks" out to the MSI team. This feature doesn't even rate. 2. This is a build issue. The MSI team isn't seriously in the build business (Orca?).

All vendors the same way? If vendors wanted to, they could all build their tools top of the WiX toolset. Obviously, all of the vendors building on top of WiX v3 today (Indigo Rose being the only commercial one I know of) automatically get this feature for free. Other vendors are welcome to do the same. Heh, then all setup tools vendors would build their packages in even more in the same way.

# re: "Smart cabbing" added to WiX toolset.

Left by Christopher Painter at 6/1/2007 1:31 PM

Funny, I thought Windows Installer was the SDK, not WiX. I think that's the nicest way I can put it Rob.

# re: "Smart cabbing" added to WiX toolset.

Left by Rob Mensching at 6/1/2007 2:04 PM

Yes, the Windows Installer has an SDK. My point revolved more around the fact that there is nothing provided in the Windows Installer SDK for creating cabinets. Additonally, the Windows Installer SDK really doesn't provide many tools for building MSI packages (yes, there is Orca and wrappers around the MSI API but those are brutal authoring evironments and they still don't provide ways to create cabinets). So I was basically arguing that your question "where is the strategy" incorrectly assumed the Windows Installer team should be responsible for this feature.

Also, Christopher, please remember that I don't work on the Windows Installer team or their SDK. I work on the WiX toolset (and Windows Marketplace). All I can really offer is to make the WiX toolset better and available to as many people as chose to use it and/or bulid on top of it.

# Mechanism for avoiding duplication?

Left by Richard at 6/1/2007 2:18 PM

Rob, what was the mechanism that you used for avoiding the duplication? Are you using two different rows in the File table with the same media sequence number?

# re: "Smart cabbing" added to WiX toolset.

Left by Christopher Painter at 6/1/2007 2:26 PM

I'm looking at it from a different perspective. It's not a build issue, it's a DuplicateFiles and MsiPublishAssemblies issue. If the standard actions supported the needed use cases, we wouldn't be having this discussion.

I know you aren't on the Windows Installer team, but I feel that a bad precedent is being set over and over by having WiX do all the work. One tools vendor shouldn't have to adopt another tools vendor's middle layer to get functionality that was already supposed to be provided for free already in the core SDK.

 re: "Smart cabbing" added to WiX toolset.

Left by Jon W at 6/4/2007 1:37 PM

Thanks Rob! I've been waiting for this due to the copyfiles and duplicatefiles lacking with repairs and network installs. This will easily save me 10MB also!

 re: "Smart cabbing" added to WiX toolset.

Left by AJ at 6/7/2007 3:24 PM

I noticed this and was pleasantly surprised. We have some web projects and there are many shared files that need to go in the different bin folders. Some files are referenced 4 or 5 times and it was nice to see my 10MB install not balloon to 35-40MB.

# re: "Smart cabbing" added to WiX toolset.

Left by Dennis at 6/15/2007 5:14 PM

Hi,

This would appear to be the original source:

http://blogs.msdn.com/heaths/archive/2005/04/15/hacking-the-cab-for-smaller-patches.aspx

Sounds to me that MAKECAB.EXE (any cab creation tools - which can also easily detect duplicates) is what needs to support this, this technique could be problematic where multiple cabs produced.

# re: "Smart cabbing" added to WiX toolset.

Left by Christopher Painter at 7/26/2007 7:46 AM

Someone recently asked me about conditionally setting the start type for a service at install time. From what I could see, the ServiceInstall table doesn't support this.

The best I can think of ( without using a custom action ) is to make 2 mutually exclusive components using conditional expressions each having a slightly different ServiceInstall table entry. This would create another scenario where a key file would waste space in the media that this pattern would be useful. Even more useful might be if the ServiceInstall StartType column was formatable.

Your comment:



 (will not be displayed)


 
 
 
Please add 5 and 5 and type the answer here:
 

Live Comment Preview: