PDA

View Full Version : MsiGetFeatureState



Jennifer
05-18-2006, 02:43 PM
It seems that I am no longer able to use MsiGetFeatureState in an installscript custom action that is set to run deferred.
Is this because of the changes that were made that now force us to use CustomActionData instead of directly getting the property value?
If so, is there a new and improved way to get the feature states/actions?
So far my workaround is to create custom actions that sets properties related to a feature. But the custom action is conditioned to run only if the feature is slated for installation. I then pass the property into CustomActionData so that another custom action can access it. But this method is so cumbersome. Is there a better way to do this?

Christopher Painter
05-18-2006, 05:19 PM
Correct, deferred CA's don't have access to this. You can however use it as a condition for the custom action since this is evaluated during immeadiate execution.

So if you have some script that only runs if a feature BOB is being installed then say &BOB=3 for the CA condition and then don't worry about implementing it in script as the CA wouldn't fire if BOB wasn't being installed.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/deferred_execution_custom_actions.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/obtaining_context_information_for_deferred_execution_custom_actions.asp

Jennifer
05-19-2006, 12:16 PM
It seems I will have a lot of changes to make in order for me to start using InstallShield 12.

Christopher Painter
05-19-2006, 09:46 PM
It's usually good to go back and reconsider how you are doing things anyways. I don't know what your CustomActions do, but now might be the time to consider if there are native ways in MSI to do what they are doing without any custom actions in the first place.

Barbara
05-22-2006, 08:44 AM
I am using a lot of MSI API calls in my deferred InstallScript custom actions. So it would be nice to have a list of MSI API Functions (such as MsiGetFeature State, MsiGetProperty) which are likely to fail in deferred execution. It would save me a lot of time and debugging because I have to maintain over 45 setup projects. And if we decide to go to IS12 it would be a lot of work for me to get all this projects working.

Barbara

Christopher Painter
05-22-2006, 09:07 AM
Read the second link that I posted above. It's a complete list of the only MSI API's requiring an MSI handle that may be called in deferred context.

Here it is again:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/obtaining_context_information_for_deferred_execution_custom_actions.asp

Christopher Painter
05-22-2006, 09:24 AM
As an aside I'd like to suggest that 1) eliminate unnessecary customactions ( reconsider the full capabilities of MSI and ask yourself if there is a way to eliminate each custom action and 2) seperate your business logic from your configuration logic. Your business logic should be immeadiate execution just prior to your deferred custom action. This way you have access to the MSI handle to evaluate your business rules and place them into the CustomActonData property. Then your deferred custom action executes, reads the CustomActionData property and executes the configuration logic. If the custom action fails a rollback is initiated and your rollback CA ( again business logic is in immeadiate and (de)configuration logic is in the deferred ).
execute because it was scheduled just prior to your installation CAs.

Jennifer
05-23-2006, 12:25 PM
Christopher,
Can you clarify that the use of these api function calls only affect custom actions that are deferred. If I have a custom action that runs immediately then I can still use MsiGetProperty to get my property value without having to use CustomActionData?

Christopher Painter
05-23-2006, 01:25 PM
Yes because a custom action running in immeadiate execution context has access to the MSI Handle. It only gets tricky when you are running deferred out of process context.

Christopher Painter
06-02-2006, 06:57 AM
When InstallSheild 12 gets released, can we move this thread to the new forum and make it a sticky?