N.B!: I don't use WixSharp, but the below should be generic. At least some of it.
Debug Custom Actions: I just follow this procedure (since I generally use native code):
- Compile debug binaries and include in the package.
- Show a message box from the custom action.
- Use Visual Studio to attach to the process showing the dialog.
- You attach to
msiexec.exe
for native, unmanaged code, and to rundll32.exe
for managed code. System context or user context process depending on how the custom action runs.
- Set a break point in code directly after the dialog and let it be hit.
- This should work provided your source code matches what is in your debug binaries in the package (debugging symbols).
How-To Video: There is a video from Advanced Installer showing most of the process: Debug C# Custom Actions. Very good.
A step-by-step description of how to use C# (managed) custom actions with WiX.
This issue has come up a lot lately, most recently in this question / answer, section 4.
Here is some aging but good content on the topic from installsite.org: Debugging Custom Actions.
I ran a test on your own suggestion to verify that it works too for a regular WiX setup (the #if DEBUG makes the code only apply to debug builds):
#if DEBUG
System.Diagnostics.Debugger.Launch();
#endif
The other command you mention works as well for me:
Debug.Assert(false);
The main challenge is to make sure the right dll version makes it into the MSI. If you don't see expected behavior try to manually insert the dll version (debug or release) that you intend to run with into the MSI using Orca or another MSI editor tool - just to make sure the right binary is in there. I don't know how this is set up in WixSharp.
Message Boxes: To show a message box from a C# custom action:
Add a project reference to the System.Windows.Forms
namespace and system assembly (both a project reference and a using in code in other words):
using System.Windows.Forms;
<..>
[CustomAction]
public static ActionResult TestCustomAction(Session session)
{
MessageBox.Show("Hello from TestCustomAction");
return ActionResult.Success;
}
Beyond using a .NET message box, you can also use MSI's built-in Win32 dialogs via the: Session.Message
call to show a dialog. This is probably better for end user dialogs. I would use the above approach for debugging only.
For Reference: Debugging Custom Actions
C++ debugging
:
Managed Code
(in addition to above):
Some Links (for safekeeping):
bin
folder first. – Farnesol