0
votes

I have a Windows Installer which has a complex interface in WPF 4.5. It uses several other MSI Installer files created for several other components using WIX which are present inside the sub directories like:

  • InstallerRootDirectory
    • WPF_Executable_File[The main installer]
    • File_A
    • File_B
    • Directory_A
    • Directory_B
    • Directory_c
      • MSI Installer 1
      • MSI Installer 2

I need the MSI Installer 2 created from WIX to be able to copy File_B to the installation direcotory for this component on the target machine.

The File_B is created at runtime from WPF_Executable_File and is not available at MSI build time.

Can I do this directly through WIX, or do I need to use a Custom Action?

I tried the following code, but it gives error:

<Component Id="cmpA9616EB16BF74D7E90C6CD0D590A18ED" Directory="dir39B22699688E51DCD8DCBB99A47E835B" Guid="{DAD3EA2B-830F-482C-8F2F-EEB3C49E6373}">
<CopyFile SourceDirectory="../../[SourceDir]" SourceName="abc.xml"  DestinationProperty="dir39B22699688E51DCD8DCBB99A47E835B" Id="copyfile1" />
</Component>

Error: SourceDirectory attribute's value is not a legal identifier

Using SourceProperty also gives the same error.

1
I think you're going to need to go with the Custom Action route. If running the .exe is the only way to generate the file, you will need to do that before you try to copy the file. Your other option is to have the exe copy the file to the needed directory when it is run and remove the file copy in the MSI Installer 2. - Kcvin
The <CopyFile> element is the right way to go in this situation. It will help if you specify the error you get. - Yan Sklyarenko
I have updated the error in the question. - teenup
CopyFile will work you just need to get the details right. You just need actual directory names, and I'm pretty sure you can't use ..\.. - PhilDW
If I can't use ..\.. then how will I go to the parent directory of [SourceDir]? Is there any way of getting the parent directory? - teenup

1 Answers

-1
votes

I would agree that <CopyFile> is a better alternate. However I have tried with Robocopy and it has worked for me.

<CustomAction Id="BaselineSync_Cmd" Property="BaselineSync" Execute="immediate"
    Value="&quot;robocopy&quot; &quot;[BUP]&quot; &quot;[PROD]&quot; /PURGE /e" />
<CustomAction Id="BaselineSync" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>

<InstallExecuteSequence>
    <Custom Action="BaselineSync_Cmd" After="StartServices"><![CDATA[NOT(Installed)]]></Custom>
    <Custom Action="BaselineSync" After="BaselineSync_Cmd"><![CDATA[NOT(Installed))]]></Custom>
</InstallExecuteSequence>

In this case I am passing BUP and PROD values when I call the installer. Something like: msiexec /i BUP=C:\somefolderpath PROD=C:\someotherfolderpath /qn /l*v install.log