12
votes

I want perform custom action after files are copy in destination folder.

In custom action i run copied script file so give me error file not found.

<CustomAction Id="RunDBScript"
              BinaryKey="CA"
              DllEntry="RunDBScript"
              Execute=" immediate"
              Return="check" />


<Custom Action="RunDBScript" After="InstallFiles">
    <![CDATA[NOT Installed]]>
  </Custom>

this custom action give an error file/directory not found. so this action call before file copy.

so, how to call custom action after file copy?

I am not understand why this custom action call before InstallFiles even though i am specified After="InstallFiles".

2
Make your CA deferred: Execute="deferred"Yan Sklyarenko
if i use Execute="deferred" then give me error : "Cannot access session details from a non-immediate custom action"Rikin Patel
How did you solve your issue?guiomie

2 Answers

7
votes

Move your custom action after InstallFinalize. This is the only place in InstallExecuteSequence where Immediate actions can be executed after installing the product files.

5
votes

When you use deferred custom actions, you must access values through session.CustomActionData["propertyname"].

Session dictionary values can be read only by immediate custom actions, where the execution script is being written.

The deferred custom actions are executed at script running time, so the project properties are no longer available. To make use of it, you must implement a double custom action in order to provide the desired properties for the real custom action.

Follow the bellow example:

<CustomAction Id="CustomActionID_Data" Property="CustomActionID" Value="INSTALLDIR=[INSTALLDIR];OTHERPROPERTY=[OTHERPRPJECTPROPERTY]"></CustomAction>
<CustomAction Id="CustomActionID" BinaryKey="FILEBINARYID" DllEntry="METHODNAMEATCUSTOMACTION" Execute="deferred"></CustomAction>

At this example, you need to call at InstallExecutionSequence the custom action "_Data" and after call the real one, so the first "_Data" will se the desired properties. Then you can access those properties on your code using session.CustomActionData[""].

Just complementing, bellow is an example of how to call the custom actions at InstallExecuteSequence.

<Custom Action="CustomActionID_Data" After="InstallFiles">NOT (REMOVE="ALL")</Custom>
<Custom Action="CustomActionID" After="CustomActionID_Data">NOT (REMOVE="ALL")</Custom>