Skip to content

Support for MSIX

Oleg Shilo edited this page Jan 4, 2025 · 2 revisions

Currently, there is no dedicated support for building MSIX. Though WixSharp si flexible enough to allow building MSIX with a very simple extension of the stock API.

This is an example of adding a FireGiant.HeatWave.BuildTools.Msix.wixext WiX elements and engaging WiX tools for building MSIX:

public class Program
{
    static void Main()
    {
        var project = new Project("MyProduct",
                              new Dir(@"%ProgramFiles%\My Company\My Product",
                                  new File("Program.cs",
                                      new MsixApplication
                                      {
                                          Id = "MyProductApp",
                                          OverrideDisplayName = "My Desktop Product"
                                      })));

        project.GUID = new Guid("72a3b240-c984-4ef8-91e2-2b0319cd0aec");

        project.BuildMsix();
    }
}

public class MsixApplication : WixEntity, IGenericEntity
{
    [Xml]
    public new string Id { get => base.Id; set => base.Id = value; }

    [Xml]
    public string OverrideDisplayName;

    public void Process(ProcessingContext context)
    {
        var extension = new WixExtension(
            "FireGiant.HeatWave.BuildTools.Msix.wixext", "msix",
            "http://www.firegiant.com/schemas/v4/wxs/heatwave/buildtools/msix");

        context.Project.Include(extension);
        context.XParent.Add(this.ToXElement(extension, "Application"));
    }
}

static class WixSharpExtensions
{
    public static void BuildMsix(this Project project)
    {
        project.WixBuildCommandGenerated += (cmd) => " -outputType msix " + cmd;
        project.BuildMsi();
    }
}

However, you will need a properly licenced (quite expensive) account from FireGiant (see this info).

There was some talk about this that you may find useful: https://github.com/oleg-shilo/wixsharp/issues/1708.

Be aware that FireGiant MSIX extension is still raw as of Jan-2025. Thus the only sample found at that time contains invalid attribute msix:Application.OverrideDisplayName and there was no documentation on the XML schema to verify or address that.