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

Urban Olars urban.olars at gmail.com
Thu Feb 9 03:52:43 PST 2017


I finally found the problem. The <Custom Action="IronCADRootDirectory"
Before="AppSearch" /> has to be inside an InstallUISequence> tag, not
inside the <InstallExecuteSequence> tag like I had done. The result from my
incorrect way of doing it was that the custom action got executed way too
late.

Thank you all for the help.

2017-02-07 9:13 GMT+01:00 Urban Olars <urban.olars at gmail.com>:

> 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
>



-- 
/Urban Olars



More information about the wix-users mailing list