Search code examples
wixcustom-action

WIX need to extract file (XML) from binary in CustomAction


I am implementing using WIX... I need to execute an EXE in the CustomAction which I am able to do it by adding EXE in Binary and calling it before installation. But this EXE needs an XML file to read data from which should be present in the current directory. For that I am able to insert the XML in the Binary just as I did for the EXE.

Now I need to extract the XML file before EXE from Binary. Not able to figure out CustomAction I need to extract it.

Following is the things i did:

  • Added XML to binary

<Binary Id="TestXML.xml" SourceFile="d:\csu\TestXML.xml"/>

  • CustomAction (which I tried - question mark "???" what to put)

<CustomAction Id="SetBinaryWrite_TargetFileName_1" BinaryKey="TestXML.xml" ExeCommand="???" Execute="immediate" Return="ignore" />

  • execution in <InstallExecuteSequence>

<Custom Action="SetBinaryWrite_TargetFileName_1" After="ValidateProductID"/>

Need help !!


Solution

  • There is no built-in support for this.

    Launching an EXE from Binary table is a native Windows Installer custom action. If you want to simply extract a file from Binary table, you need to write your own custom action using custom code.

    You can try using a win32 DLL which receives the installation handle and uses the Windows Installer API to extract the file.