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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s