[wix-users] CustomAction does not seem to be called from the msi
Urban Olars
urban.olars at gmail.com
Wed Feb 8 22:14:40 PST 2017
There is no CustomActions.CA.dll being created. I am using Visual Studio
2010 and used the WIX template for C++ Custom Action when creating my
project. Are you sure that there should be any *.CA.dll created for C++
custom actions? I am only guessing now but after Googling for this subject,
it seems like C# custom action projects create a *.CA.dll but not C++
custom action projects. Could this be the case?
2017-02-07 16:16 GMT+01:00 Justin Cox <cox.justin.a at gmail.com>:
> You should be targeting the CustomsActions.CA.dll. Is it getting built in
> your bin\release folder? If not, you need to add it to you assembly and
> target that.
>
> On Tue, Feb 7, 2017, 4:15 AM Tom Brezinski <tom.brezinski at viavisolutions.
> com>
> wrote:
>
> > I have two ideas for you...
> >
> > First is your action might not be getting pulled in. For WiX to include
> a
> > fragment it has to get tied back into the core <product> somehow. I
> > separate out my actions into their own WXS file / fragment which put them
> > out of scope.
> >
> > In order for them to be part of the install I have to put this at the top
> > of the fragment that has the actions:
> > <!-- Bogus folder so we can reference it to pull in this fragment
> > -->
> > <DirectoryRef Id="INSTALLFOLDER">
> > <Directory Id="LegacyUpgradeActionsFolder" />
> > </DirectoryRef>
> >
> > And then inside the fragment that I specify my features I include a Ref
> to
> > that folder:
> > <!-- Reference the bogus actions folder so that fragment gets pulled in.
> > -->
> > <DirectoryRef Id="LegacyUpgradeActionsFolder"/>
> >
> > Second idea is change the CustomAction to Execute="immediate" and
> schedule
> > it After="AppSearch" to make sure it happens really early. I am not sure
> > when the Condition element will be evaluated but I am sure it is quite a
> > bit before InstallInitialize. Also I am not sure when firstSequence will
> > schedule the action but I know that once the install elevates it is
> > difficult to use WcaSetProperty.
> >
> > If you do not have Orca download it. Opening your MSI and seeing exactly
> > what was built, what order actions were sequenced in, etc is very
> valuable
> > for debugging.
> >
> > -----Original Message-----
> > From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On
> Behalf
> > Of Urban Olars
> > Sent: Tuesday, February 07, 2017 2:13 AM
> > To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
> > Subject: [wix-users] CustomAction does not seem to be called from the msi
> >
> > 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
> >
> > ____________________________________________________________________
> > WiX Toolset Users Mailing List provided by FireGiant
> > http://www.firegiant.com/
> >
> > ____________________________________________________________________
> > WiX Toolset Users Mailing List provided by FireGiant
> > http://www.firegiant.com/
> >
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>
--
/Urban Olars
More information about the wix-users
mailing list