WiX – Managed Custom Actions
Da das Windows-Installer Team sich weigert den Windows-Installer zur Unterstützung von “Managed Custom Actions” zu erweitern (siehe hier) muss man als WiX nutzer Umwege finden um dieses “Feature” zu nutzen.
In dem angehängten Packet ist der benötigte Code enthalten um in einer Custom Action aus einer C++-Library heraus die CLR zu hosten und eigene Assembly’s auszuführen als Managed Custom Actions.
Der komplette Code ist nicht auf meinem Mist gewachsen, sondern aus der Verbindung zweier Projekte entstanden:
1. “Wrapping the Windows Installer 2.0 API” - Ian Mariano
2. “Hosting the CLR within a custom action” - Pablo M. Cibraro (aka Cibrax)
Der Beigefügte Code dient als Beispielcode, kommt als Solution für Visual Studio 2005. Die WiX-Votive Erweiterung in der Version 3.0 (beta) wird ebenfalls benötigt.Â
ManagedCustomActions Codesample
Tags: WiX
10. September 2007 um 17:05
Thanks so much Oliver
I will take a look at it and ping you if I have any questions
danke
rachna
——————————————————————————–
From: wix-users-bounces@lists.sourceforge.net [wix-users-bounces@lists.sourceforge.net] On Behalf Of Mailinglist [Mailinglist@prodot.de]
Sent: Monday, September 10, 2007 12:29 AM
To: wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] Managed custom action return values
Hello,
Writing managed custom actions is not supported. A standalone executable will not see anything of the setup around.
I took two half ready projects and used them, to build up something that gives you the possibility to write managed custom actions and access the current setup from within your managed code, so you can e.g. post a return value to a property in your setup. You can fetch the code and the samples under the following link: http://www.forestwalk.de/?p=31 sorry, my entry is just in German, but it’s the latest link in the post you need. The source and comments are in English though.
If you need help in using this, feel free to ask back to me.
Oliver
From: wix-users-bounces@lists.sourceforge.net [mailto:wix-users-bounces@lists.sourceforge.net] On Behalf Of Rachna Khune
Sent: Sonntag, 9. September 2007 04:53
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] Managed custom action return values
Hi there
My custom action is a managed exe and I am attempting to do one of the two choices below:
1) Show the exception messages from the custom action or be able to return some error codes which I can log
2) Change the message that pops up when the custom action fails. The default is “There is a problem with this windows…â€. Is there any way of changing this default message?
The Error attribute cannot coexist with the ExeCommand attribute in the CustomAction element:
Current implementation:
Seems as if writing managed custom actions is not preferred due to messages popping up and not having access to the MSI thread.
Thanks
Rachna
SDE Repository & Modeling Team, CSD
Microsoft
425.705.6966 rachnak@microsoft.com
Cell: 425.533.1626
11. September 2007 um 18:07
Hi Oliver
I saw your post on the wiz users list in response to Phil’s
I also saw your example above, however, the custom actions in your sample are managed dll’s not exe.
My custom action is an exe since i need to pass in the install location through the ExeCommand attribute. Hence, I am stuck with displaying Wix default error messages. I cannot use the Error attribute along with the customaction element. This would be a compile error.
Thanks
Rachna
11. September 2007 um 20:49
Hi Rachna,
spontaneusly I consider 2 ideas for you:
First one if your .net exe is only for that custom action, you could turn it into a dll, and set the parameter in Wix as a property, that you can read inside the dll via the installercontext.
Second one would be, that you modify the loader app for the custom action runtime, that it does not call a specified dll, but a .net exe with a commandline parameter from a property of the installer context. Well, if you give me some time, i could modify it like that for you.
Oliver
25. Januar 2008 um 18:03
Hi Oliver,
this is very good work. Thanks!
I have a question on debugging. I am sure it must be possible to debug into the managed code but I do not succeed:
I add the pdb files to the temp folder where the assemblies are stored and attach the process after having broken the process showing a messagebox from the CLRHosting code. In C++ code I can debug without problems, but in managed code no break point can be set.
Do you have an idea what I should check. Am I doing anything the wrong way? I have not so much experience with unmanaged code. So I’d be glad to get some help.
Massimo
05. Februar 2008 um 07:08
I am sorry, but I do have no idea how to debug the code. In my custom actions I use extensive logging instead of debugging.
Oliver
11. April 2008 um 15:43
Hi Axel,
you will have to add these three DLLs as binaries into your WiX-Project.
Debugging is a little bit difficult, since you do not get any error written to the log of the msi. I got used to work with the Trace Object inside my CustomActions, and let every CustomAction create a log in %temp%.
Hope it helps.
BeowulfOF