[wix-users] CustomAction does not seem to be called from the msi

Urban Olars urban.olars at gmail.com
Tue Feb 7 00:13:26 PST 2017


Hi,

I am trying to learn how to write custom actions in C++ and how to use them
in my msi installation project. Unfortunately with no luck so far. I have
looked at numerous examples I have found on internet but still have not
found out what I am doing wrong. I kindly ask for input from someone on
this mailing list. Thank you in advance.


This is part of the code in my *.wxs file:
<Binary Id="CAICRoot"
SourceFile="..\CustomActions\CustomActions\bin\Release\CustomActions.dll" />
<CustomAction Id="IronCADRootDirectory" BinaryKey="CAICRoot"
DllEntry="GetICRootDir" Execute="firstSequence" HideTarget="no" />

<InstallExecuteSequence>
<Custom Action='IronCADRootDirectory' Before='InstallInitialize'/>
<RemoveExistingProducts Before="InstallInitialize"></RemoveExistingProducts>
</InstallExecuteSequence>

<Condition Message="IronCAD root directory not found. Installation
aborting">
<![CDATA[ICROOTDIR]]>
</Condition>
...
...


This is part of the code in my custom action dll:
UINT __stdcall GetICRootDir(MSIHANDLE hInstall)
{
MessageBox(NULL , _T("It got called!") , _T("Title") , MB_OK);
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
// Initialize WiX Custom Action
hr = WcaInitialize(hInstall, "GetICRootDir");
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");

if (hr == ERROR_SUCCESS)
{
LPWSTR lpwString = L"C:\\Program Files\\IronCAD";           // This is just
for testing. In reality I will look it up in the registry and cut away part
of the string
hr = ::WcaSetProperty(TEXT("ICROOTDIR"), lpwString);
ExitOnFailure(hr, "Failed to set property");
}
...
...


My msi project builds without errors but when I run the msi file, it always
stops at the condition message. Obviously, no property called ICROOTDIR has
been set. I added code for a message box in the custom dll so I should know
that the function at least gets called but this message box has never
showed up so far. My assumption is therefore that I have missed something
fundamental so the custom dll never even gets called.

I have added the entrypoint in the *.def file of my custom dll project:
LIBRARY "CustomActions"

EXPORTS

GetICRootDir


I haven't learnt yet how to log what is happening but I guess I will have
to unless someone of you can see right away what the problem is.



Regards
Urban Olars


More information about the wix-users mailing list