Skip to Content

Simplifying the WiX v3 language

Two recent changes that simplify the WiX language will be available in the next weekly release of WiX v3. The goal of both changes is to make simple setup authoring simpler and help reduce redundancy.

Assigning components to features via attribute

The Component element now has a Feature attribute; when set, that component is parented to the specified feature. So the following snippets are equivalent:

<Component Id="FooComp" Feature="BarFeature" ... />

and

<Component Id="FooComp" ... />
...
<FeatureRef Id="BarFeature">
  <ComponentRef Id="FooComp" />
</FeatureRef>

Component/@Feature supports one feature reference. You can still parent one component to multiple features using Feature or FeatureRef and ComponentRef. This change is to simplify the more common case of one component parented to one feature.

Default File Id and Name from Source

Typical File element authoring has several attributes with similar values. A File’s Id, Name, and Source elements might all mention the same file name, for example. WiX v3 already has several defaults that simplify File element authoring, like defaulting the Name attribute value to that of the Id attribute.

The File element now takes the default for the Id attribute from the file name portion of the Source attribute. The Name attribute then gets its default value from Id, so authoring a File element can now be as simple as:

<File Source="$(env.Bits)\foo\bar\baz.exe" />

The equivalent would be:

<File Id="baz.exe" Name="baz.exe" Source="$(env.Bits)\foo\bar\baz.exe" />

Simple change, simple benefit

The code changes for these two features were trivial. But I think they represent the kind of schema changes you’re likely to see as we head to a WiX v3 stabilization, as Rob mentioned earlier this year. A simpler language makes it easier for designers to generate clean code and for those who prefer hand authoring to minimize unnecessary typing.