VS2019 – 2022 Templates - oleg-shilo/wixsharp Wiki

Wix# comes with various VS2019/2022 project/item templates. They are all packed into Visual Studio Extension - WixSharp Project Templates, which can be downloaded from the Visual Studio Gallery or directly installed from the VS Extension manager.

The extension includes 5 project templates. The type of the project is reflected in the temple name. I.e. "WixSharp Managed Setup - Custom UI" is template for the managed project WixSharp that has source code for all UI dialogs included in the Visual Studio project.


WiX Toolset installation

Wix# does require WiX binaries (compilers, linkers etc.). Wix# is capable of automatically finding WiX tools only if WiX Toolset installed. In all other cases, you need to set the environment variable WIXSHARP_WIXDIR or WixSharp.Compiler.WixLocation to the valid path to the WiX binaries.

WiX binaries can be brought to the built environment by either installing WiX Toolset, downloading Wix# suite or by adding WixSharp.wix.bin NuGet package to your project. For bringing WiX Tools from NuGet use Install-Package WixSharp.wix.bin command.

MSI Authoring Steps

It is important to understand what is involved in building the MSI as otherwise it may be quite uneasy to troubleshoot the integration problems associated with the use of NuGet,VS and MSBuild.

Every Wix# VS project is a C# project that defines building an exe. This exe is an "MSI builder", which if executed uses WiX compilers to produce the final msi.

Thus if you just create manually a simple ConsoleApp project with the Wix# code (as below) and compile it it will build an exe but not msi.

class Script
    static public void Main()
        var project = new Project("CustomActionTest",
                new ManagedAction("MyAction", Return.check, 
                                   When.After, Step.InstallInitialize, 


public class CustomActions
    public static ActionResult MyAction(Session session)
        MessageBox.Show("Hello World!");
        return ActionResult.Success;

However if you run the produced exe (e.g. F5) it in turn will build the desired msi. Instead of running the exe manually every time you can automate it by setting the project post-build event: post-build event image

All Wx# VS samples are composed this way.

Note, you don't have to set up post-build event manually if you use WixSharp Nuget package with Visual Studio. The package installation script does it automatically for you. All proper Wix# Visual Studio project templates also come with the post-build exe execution already scheduled. Though not via the post-build events but rather with *.targets, but that doesn't make any difference for the user.