Debugging Custom Actions in Windows Installer

In Visual Studio, you can add Setup Projects and WiX projects. Especially WiX projects are very powerful. Unfortunately, you cannot run the generated Msi-Package in debug mode to be able to step into your own custom actions. Well, the solution is simple: just add a call to the Debugger.Launch method wherever you want to step into your code. Example:

[CustomAction]
public static ActionResult MyCustomAction(Session session)
{
    // Start debugging here:
    System.Diagnostics.Debugger.Launch();

    session.Log("Begin CustomAction");

    // Actual action here...

    session.Log("End CustomAction");

    return ActionResult.Success;
}

Now, when the Msi-package is executed normally, the debugger will launch as soon as the custom action is called. At hat point, the Visual Studio Just-In-Time Debugger will pop up.

Freelance full-stack .NET and JS developer and architect. Located near Cologne, Germany.

Leave a Reply

Your email address will not be published. Required fields are marked *