WixSharp.Core 2.4.2

dotnet add package WixSharp.Core --version 2.4.2                
NuGet\Install-Package WixSharp.Core -Version 2.4.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WixSharp.Core" Version="2.4.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WixSharp.Core --version 2.4.2                
#r "nuget: WixSharp.Core, 2.4.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install WixSharp.Core as a Cake Addin
#addin nuget:?package=WixSharp.Core&version=2.4.2

// Install WixSharp.Core as a Cake Tool
#tool nuget:?package=WixSharp.Core&version=2.4.2                

stand with Ukraine

Build status NuGet version (WixSharp) Donate

paypal

<img align="right" src="https://github.com/oleg-shilo/wixsharp/blob/master/Documentation/wiki_images/wixsharp_logo.png" alt="" style="float:right">

Wix# (WixSharp) - managed interface for WiX

Framework for building a complete MSI or WiX source code by using script files written with the C# syntax.

This is a .NET Core release that is currently under reliability testing. For the product information please visit: https://github.com/oleg-shilo/wixsharp

How to use

Create project

Note, when .NET-Core packages are fully released they will come along with the Visual; Studio project templates as .NET-Framework packages do currently. But until it happens you will need to create your project manually or use this sample as a starting point.'

Steps:

  1. Create an ordinary Console Application project targeting .NET 8 and Windows: alt text

  2. Set post-build event command to:

    cd .\
    set ide=true
    dotnet "$(TargetPath)"
    

    alt text

  3. Add Nuget Package WixSharp.Core

Define setup build script

In your Program.cs file define:

using WixSharp;
using WixToolset.Dtf.WindowsInstaller;
using File = WixSharp.File;

Console.WriteLine(Environment.CurrentDirectory);

var project =
    new Project("My Product",
        new Dir(@"%ProgramFiles%\My Company\My Product",
            new File("program.cs")),
        new ManagedAction(Actions.CustomAction),
        new ManagedAction(Actions.CustomAction2),
        new Property("PropName", "<your value>")); ;

project.PreserveTempFiles = true;

project.UI = WUI.WixUI_ProgressOnly;

project.BuildMsi();

// -----------------------------------------------
public class Actions
{
    [CustomAction]
    public static ActionResult CustomAction(Session session)
    {
        Native.MessageBox("MSI Session\nINSTALLDIR: " + session.Property("INSTALLDIR"), "WixSharp - .NET8");

        return ActionResult.Success;
    }

    [CustomAction]
    public static ActionResult CustomAction2(Session session)
    {
        SetupEventArgs args = session.ToEventArgs();

        Native.MessageBox("WixSharp RuntimeData\nMsiFile: " + args.MsiFile, "WixSharp - .NET8");

        return ActionResult.UserExit; // terminate the setup
    }
}

When you build the project the MSI will be produced in your project root folder.

Note, because custom action are AOT compiled they have tendency to grow in size and add build time overhead try to avoid adding to much code that has other library dependencies unless you are OK with the impact.

Thus the custom action above uses Native.MessageBox which is nothing else but a Win32 MessageBox function. In the test environment the compile time is ~10 seconds. However replacing it with System.Windows.Forms.MessageBox adds quite a few aditional assemblies (e.g. WPF) and bumps compile time to a minute. This is a limitation of AOT compilation.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.4.2 206 10/27/2024
2.4.1 186 10/5/2024
2.4.0 185 9/21/2024
2.3.2 295 8/10/2024
2.3.1 92 8/4/2024
2.3.0 171 7/13/2024
2.2.0 139 6/29/2024
2.1.7 416 5/27/2024
2.1.6 1,410 5/1/2024
2.1.5 2,455 4/6/2024
2.1.4 158 3/20/2024
2.1.4-hotfix 104 3/19/2024
2.1.3 946 3/6/2024
2.1.2 220 3/4/2024
2.1.1-pre 95 2/25/2024