Skip to content
Oleg Shilo edited this page Aug 4, 2024 · 26 revisions

Wix# (WixSharp) managed interface for WiX

The project has been migrated to GitHub from CodePlex: Wix#. Thus some links may still point to CodeProject Wiki articles.

The first publicly available version of Wix# was published in 2009 on CodeProject. The original CodeProject article along with this interview for InfoQ offer the best explanations of the reasons behind Wix#. They describe very well the problems and common deployment challenges that Wix# is trying to solve. They also provides a good overview of the existing deployment authoring solutions and approaches.

Wix# is a framework for building a complete MSI or WiX source code by using script files written with the C# syntax. The simple code snippet below is a typical MSI setup authored with Wix#:

using System;
using WixSharp;
 
class Script
{
    static public void Main(string[] args)
    {
        var project = new Project("MyProduct",
                          new Dir(@"%ProgramFiles%\My Company\My Product",
                              new Dir("Tools",
                                  new Files(@"Tools\*.*"
                              new File(@"Files\Docs\Manual.txt"),
                              new File(@"Files\Bin\MyApp.exe")));
 
        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
 
        Compiler.BuildMsi(project);
    }
}

Dependencies

You can build MSI/Burn binaries either with Visual Studio, VSCode or CS-Script (Python like C# scripting engine).

WixSharp uses various msi authoring tools (e.g. compiler, linker) that are part of WiX Toolset. Meaning that you need to install WiX toolset. You have a few options:

  • WiX3
    • Install it from WiX home page or
    • Import it as a WixSharp nuget package (WixSharp.wix.bin) in your project.
  • WiX4
    • Install it as a .NET tool (requires .NET SDK)
      dotnet tool install --global wix
      
      Building MSI without .NET SDK...
      WixSharp by design relies on WiX toolchain. Thus WiX Toolset needs to be deployed on the build system. WiX Toolset in turn relies on .NET SDK as a default distribution mechanism for WiX tools. Thus you need to install .NET SDK v8.0 or higher.

      WixSharp has no runtime dependency on .NET SDK and it can fully function without it. However, it may still try to use dotnet.exe (part of SDK) to automatically install WiX tools if they are not present.

      If for whatever reason you want to build msi on a system that does not have .NET SDK installed you need to bring all WiX tools by any other means. You will also need to disable WixSharp auto-installation of WiX Tools. You can do that starting from v2.3.0 by setting the location of all WiX tools manually:

      WixTools.SignTool = @"\signtool.exe";
      WixTools.MakeSfxCA = @"\WixToolset.Dtf.MakeSfxCA.exe";
      WixTools.Heat = @"\heat.exe";
      WixTools.DtfWindowsInstaller = @"\WixToolset.Dtf.WindowsInstaller.dll";
      WixTools.WixToolsetMbaCore = @"\WixToolset.Mba.Core.dll";
      WixTools.SfxCAx64 = @"\x64\SfxCA.dll";
      WixTools.SfxCAx86 = @"\x86\SfxCA.dll";
      WixTools.WixExtensionsDir = @"%userprofile%\.nuget\packages";
      

You will need to use at least one NuGet package WixSharp.bin and have WiX installed (can also be used as a package).

Note, it is highly recommended that instead of importing packages manually you create your Visual Studio project from the appropriate WixSharp template.

These are the packages that you can use: nuget list wixsharp*

Documentation

The Wix# documentation comes in the following forms:

  • XML code documentation
    XML documentation contains the code samples (embedded in the class summaries) as well as the complete description of all class members. While the code documentation is available in the form of API Reference CHM help file it is not intended to guide the developers through the development but rather assist with the codding.

  • Code samples
    Extensive collection of the code samples (\Samples) from release package. This is the most useful source of information and the best way of learning Wix#. All samples are self-sufficient and cover an extremely wide range of the deployment scenarios. The code samples make a significant part of the total Wix# codebase volume. you can also browse read-only samples directly in GitHub samples folder

  • Wiki

  • Code Contribution Guideline
    A small set of development points to assist developers with contributing to the Wix# project.


Additional/External Documentation: