Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call custom action after files copied in wix

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".

like image 353
Rikin Patel Avatar asked Jul 05 '12 14:07

Rikin Patel


2 Answers

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

like image 178
rmrrm Avatar answered Oct 20 '22 06:10

rmrrm


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>
like image 23
Fernando Jaconete Avatar answered Oct 20 '22 08:10

Fernando Jaconete