Search code examples
wixcustom-actionrobocopy

Calling robocopy from wix customaction errors out


I have a wix custom action

<CustomAction Id="BaselineSync_Cmd" Property="BaselineSync" Execute="immediate"
    Value="&quot;robocopy&quot; &quot;[SI_BUP]&quot; &quot;[SI_PROD]&quot; /PURGE" />
<CustomAction Id="BaselineSync" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>
<CustomAction Id="RoboCopy_Cmd" Property="RoboCopy" Execute="immediate"
    Value="&quot;robocopy&quot; &quot;[INSDIR]&quot; [SI_PROD]" />
<CustomAction Id="RoboCopy" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>

The earlier robocopy command works for me but not the second. While installing, I pass the values of SI_BUP, INSDIR and SI_PROD via the commandline. Something like this: INSDIR=C:\testing\CONTENT SI_BUP=C:\testing\BACKUP SI_PROD=C:\testing\PROD /qn /l*v install.log

Log from first custom action:

MSI (s) (74:88) [15:00:52:118]: Executing op: CustomActionSchedule(Action=BaselineSync,ActionType=3137,Source=BinaryData,Target=CAQuietExec,CustomActionData="robocopy" "C:\testing\BACKUP" "C:\testing\PROD" /PURGE /e)

CAQuietExec:  -------------------------------------------------------------------------------
CAQuietExec:     ROBOCOPY     ::     Robust File Copy for Windows                              
CAQuietExec:  -------------------------------------------------------------------------------
CAQuietExec:  
CAQuietExec:    Started : Thu Jun 19 15:00:52 2014
CAQuietExec:  
CAQuietExec:     Source : C:\testing\BACKUP\
CAQuietExec:       Dest : C:\testing\PROD\

Log from the second custom action:

MSI (s) (74:88) [15:00:52:190]: Executing op: CustomActionSchedule(Action=RoboCopy,ActionType=3137,Source=BinaryData,Target=CAQuietExec,CustomActionData="robocopy" "C:\testing\CONTENT\" "C:\testing\PROD" /e)

CAQuietExec:  
CAQuietExec:  -------------------------------------------------------------------------------
CAQuietExec:     ROBOCOPY     ::     Robust File Copy for Windows                              
CAQuietExec:  -------------------------------------------------------------------------------
CAQuietExec:  
CAQuietExec:    Started : Thu Jun 19 15:00:52 2014
CAQuietExec:  
CAQuietExec:     Source : C:\testing\CONTENT" C:\testing\PROD \e\
CAQuietExec:       Dest - 

I am not able to figure out what I should be doing such that robocopy works fine. I'm not looking at a batch approach for making this happen... just customaction. Please help.


Solution

  • <CustomAction Id="BaselineSync_Cmd" Property="BaselineSync" Execute="immediate" 
        Value="&quot;robocopy&quot; &quot;[SI_BUP]&quot; &quot;[SI_PROD]&quot; /PURGE /e" />
    <CustomAction Id="BaselineSync" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>
    <CustomAction Id="RoboCopy_Cmd" Property="RoboCopy" Execute="immediate"
        Value="&quot;robocopy&quot; &quot;[INSDIR]$(var.AppName)&quot; &quot;[SI_PROD]&quot; /e" />
    <CustomAction Id="RoboCopy" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>
    

    A little change on the second customaction as shown above -RoboCopy_Cmd where I added $(var.AppName) which is set in the msbuild file from where this customaction is being called and a slight change in the commandline argument achieved the desired result.

    The commandline now looks like:

    INSDIR=C:\testing\CONTENT SI_BUP=C:\testing\MyProd SI_PROD=C:\testing\PROD\MyProd
    

    In the msbuild file AppName is set as:

    <AppName>MyProd</AppName>
    

    and INSDIR is the location where the product is installed. So the contents are installed to C:\testing\CONTENT\MyProd