VS2013/2015 Templates

Wix# comes with various VS2013/2015 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 and one item template (Custom UI Dialog).

Note, while VS templates allows embedding NuGet package configuration this feature has been reported as causing major headache for some Wix# users. The automatic package restoring happens to be fragile and it may not work reliably in some Visual Studio environments. 

Thus the package information has been removed (at least for now) from the all project templates and user is required to add the package manually after creating the project from the template:

 

WiX Toolset installation

Wix# does require WiX binaries (compilers, linkers etc.). Wix# is capable of automatically finding WiX tools only ifWiX 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 build 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 troubleshot integratioon problems associated with the use of NuGet,VS and MSBuild.

every WixSharp 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,
Condition.NOT_Installed)); project.BuildMsi(); } } public class CustomActions { [CustomAction] 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:

All Wx# VS samples are composed this way.

All proper WixSharp VS project templates already come with the post-build exe execution scheduled. Though not via the post-build events but rather with *.targets, but that doesn't make any difference for the user.

Last edited Apr 18, 2016 at 3:27 AM by oleg_s, version 10