views:

1163

answers:

3

I want to create a CustomAction C# dll that depends on a third party .Net DLL (in this specific case, its MySql.Data.dll). I have the C# custom action dll 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 3rd party dll 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 3rd party dll (MySql.Data.dll) in order to get the custom action to run?

Can I just add another Binary tag with the 3rd party dll?

+1  A: 

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.

Peter Lillevold
That won't work. None of the extra binary streams are extracted.
Rob Mensching
+3  A: 

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.

Rob Mensching
This did appear to just work, possibly because of the custom action build process handles adding these dependencies. If I understand it correctly, they become part of the .CA.dll that is generated by the Custom Action build.http://blogs.msdn.com/jasongin/archive/2008/05/23/custom-action-project-templates.aspx
Adam Tegen
A: 

Set 'Copy Local' property on the hard reference to True in Visual Studio.

David