views:

26

answers:

1

Is it possible to set a public property (say MYPROPERTY) from a C# custom action? I can read properties with Context.Parameters["MYPROPERTY"] that I pass into the custom action data but is there a way to set them too?

Thanks.

A: 

I don't know of a way to do it. In most cases, it would be impossible. Visual Studio's setup and deployment projects set their .net custom actions to run "deferred", meaning they run after the msi installation objects have been disposed. Here's the list of the possible operations in that context.

To verify that your .net custom actions are running deferred, use Orca to open the msi file and go to the CustomAction table. If the InstallUtil (VS's utility library that is placed in the "Binary" table of the MSI by VS and exposes a 'C' entry point to MSI that calls into a .NET installer assembly's installation entry points) actions have "3073" as their "Type", that means that they are running as deferred execution (3073 is msidbCustomActionTypeInScript + msidbCustomActionTypeNoImpersonate + msidbCustomActionTypeDll.)

If you create a 'C' custom action in a DLL and put it in your MSI it with a Type of "1" you can execute it during the install sequence and change properties. Unfortunately, VS's install project doesn't support that; it runs every custom action deferred as far as I can tell.

David Gladfelter
Visual Studio's installer is very limited. You may want to consider moving to WIX (Windows Installer XML) + DTF (Deployment Tools Foundation.) WIX gives you full control over the resulting MSI in a more scriptable/usable manner than the raw MSI API's and the DTF supports much more flexible and usable .NET custom actions than what you get from VS setup+deployment projects.
David Gladfelter