Creating a Simple WiX Extension

Windows Installer XML (WiX) v3.0

Creating a Simple WiX Extension

WiX extensions are used to extend and customize what WiX builds and how it builds it.

The first step in creating a WiX extension is to create a class that extends the WixExtension class. This class will be the container for all the extensions you plan on implementing. This can be done by using the following steps:

  1. In Visual Studio, create a new C# library (.dll) project named SampleWixExtension.
  2. Add a reference to wix.dll to your project.
  3. Add a using statement that refers to the Microsoft.Tools.WindowsInstallerXml namespace.
    using Microsoft.Tools.WindowsInstallerXml;
    
  4. Make your SampleWixExtension class inherit from WixExtension.
    public class SampleWixExtension : WixExtension {}
    
  5. Add the AssemblyDefaultWixExtensionAttribute to your AssemblyInfo.cs.
    [assembly: AssemblyDefaultWixExtension(typeof(SampleWixExtension.SampleWixExtension))]
    
  6. Build the project.

Although this WiX extension will not do anything yet, you can now pass the newly built SampleWixExtension.dll on the command line to the Candle and Light by using the -ext flag like the following:

candle.exe Product.wxs -ext SampleWixExtension.dll
light.exe Product.wxs -ext SampleWixExtension.dll