I have a custom action using CAQuietExec that is failing in certain scenarios - the only error messages appear in the log file which is great for me as a developer, and useless for the end user. My goal is to catch the failed action and preset a standard error message prior to rolling back installation.
To do that, based on my research I decided I'd need to write my own custom action dll so I started following this tutorial. At this stage my dll is only logging a test message and trying to pass an error message back to the dialog screens. However when I compile and run the msi, nothing happens at all - nothing logged and no error messages anywhere. Looking at the msi in Orca, it looks OK to me - but as you can see below the test dll should be causing installation to abort immediately if it actually runs and it doesn't.
So my question: Am I going about providing feedback to the user in the best way? And if so, any ideas why my custom action isn't getting run?
Thanks
CustomAction.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
using System.Collections.ObjectModel;
using System.Management.Automation;
namespace MyCustomActions
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("Begin CustomAction1");
DisplayMSIError(session, "A test message");
return ActionResult.Failure;
}
static void DisplayMSIError(Session session, String msg)
{
var r = new Record();
r.SetString(0, msg);
session.Message(InstallMessage.Error, r);
}
}
}
Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="MyPackage" Language="1033" Version="0.0.0.1" Manufacturer="Acme" UpgradeCode="GUID">
<Package InstallerVersion="300" Compressed="yes" InstallScope="perMachine" />
<Binary Id="MyCustomActions.CA.dll" src="MyCustomActions\MyCustomActions.CA.dll" />
<CustomAction Id="MyCustomActionsTest"
Return="check"
Execute="immediate"
BinaryKey="MyCustomActions.CA.dll"
DllEntry="CustomAction1" />
<InstallExecuteSequence>
<Custom Action="MyCustomActionsTest" After="LaunchConditions" />
...
</InstallExecuteSequence>
</Product>
</Wix>