Skip to Content

Simplifying WiX component authoring

In the latest in the ongoing series of simplifying the WiX language, I recently added two new defaults to the WiX compiler:

These changes will appear in the first weekly release of WiX v3.5 in 2010.

Combine the two features and a single-file component can now be as simple as:

<Component>
  <File Source="foo.exe" />
</Component>

In this case, the component’s id will be “foo.exe” because the File element’s default for its Id is the filename portion of the Source attribute. Call it hygenic double-dip defaulting.

A multi-file component isn’t suitable for generated GUIDs, so it requires an explicit GUID but can still take advantage of default component ids:

<Component Guid="{A5B56773-5E26-4C5F-AC51-C2470C3658AF}">
  <File Source="foo.dll" />
  <File Source="bar.dll" />
  <File Source="bob.exe" KeyPath="yes" />
</Component>

In this case, the component’s id will be bob.exe from the keypath File element’s default Id. Note that unless you use the generated GUID default and live within its rules, you must specify an explicit KeyPath attribute value of yes on the resource whose id you want to be the component id.

We can’t eliminate the dread component rules but we can make it simpler to live within them.