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:
- In Visual Studio, create a new C# library (.dll) project named SampleWixExtension.
- Add a reference to wix.dll to your project.
- Add a using statement that refers to the Microsoft.Tools.WindowsInstallerXml namespace.
using Microsoft.Tools.WindowsInstallerXml;
- Make your SampleWixExtension class inherit from WixExtension.
public class SampleWixExtension : WixExtension {}
- Add the AssemblyDefaultWixExtensionAttribute to your AssemblyInfo.cs.
[assembly: AssemblyDefaultWixExtension(typeof(SampleWixExtension.SampleWixExtension))]
- 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