How do I create custom actions and link it to my WiX setup project?
I have:
You need to create a new C# Custom Action Project for WiX v3 in your solution.
That should look like this:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
namespace CustomAction
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction(Session session)
{
session.Log("Begin CustomAction");
return ActionResult.Success;
}
}
}
Change the function name to a name that fits your function.
After that right click on the References Folder on your WiX setup project and choose Add Reference... .
Click the tab Projects and choose your custom action Project.
For the last step you need to add this code to your Product.wxs:
You only need to change a few names here:
Thats it.
If you now want to call the custom action in your setup project, you only need to create a "Custom" element with an Action attribute with your custom action id as value like this:
You can insert the custom action into the UI sequence or the install sequence as follows:
NOT Installed
You can also call a custom action from an event in a dialog box (snippet only - somewhat involved):
<...>
1
<...>