Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a WiX custom action DLL file with dependencies

Tags:

I want to create a CustomAction C# DLL file that depends on a third-party .NET DLL (in this specific case, it's MySql.Data.dll). I have the C# custom action DLL file working with the WiX fragment below. I'm just trying to figure out how to safely add a dependency to the custom action. Note: I don't actually need this third-party DLL file file for the installed application to run.

  <Binary Id="MyCustomAction.dll" SourceFile="MyCustomAction.CA.dll" />    <CustomAction Id="FixupConfigForMysql" Return="check" />    <InstallExecuteSequence>      <Custom Action='FixupConfigForMysql' After='InstallFiles'>NOT Installed</Custom>   </InstallExecuteSequence> 

Do I need to install the third-party DLL file (MySql.Data.dll) in order to get the custom action to run?

Can I just add another Binary tag with the third-party DLL file?

like image 203
Adam Tegen Avatar asked Oct 19 '09 23:10

Adam Tegen


2 Answers

DTF in the WiX toolset has a mechanism to include your custom action assembly and all of its references into a single binary (self-extracting dll, basically). I don't write managed custom actions (C/C++ creates custom actions with fewer dependencies and increases success rate) but it is supposed to just work when building in VS.

like image 133
Rob Mensching Avatar answered Sep 18 '22 13:09

Rob Mensching


You can use <Binary /> to add whatever files are needed to run custom actions. That should go for any 3rd party dlls you require too. Files included using the binary element are only used during installation and will not be regarded as part of the application being installed.

Update: the connection between a CustomAction and a Binary is done by referencing the binary from the custom action using the BinaryKey attribute.

Unless you can have multiple BinaryKey attributes (I have not tried this and does not directly see any support for this in the MSI custom action table) you can only have a custom action depending on one binary. That binary will thus need to carry all necessary dependencies within itself.

That said, if your dlls are all .Net assemblies, an idea would be to use ILMerge to package them into one single assembly.

like image 21
Peter Lillevold Avatar answered Sep 20 '22 13:09

Peter Lillevold