0

I need to include a dll/exe in the resulting MSI (created through a WiX project), but I do not want to deploy them during installation: I only want to use them in some CustomAction my purpose is to include an existing exe/dll and call it during installation from wxs code (not from a CustomAction dll).
Is it possible to include files which are not deployed during installation? I mean, only pack them inside the resulting MSI, and call them for some task while they are unpacked inside %temp% folder?
Also, it would be nice if somebody could show some sample code of how to include dll/exe through the Product.wxs XML code unit.
Thanks.

scrat.squirrel
  • 3,607
  • 26
  • 31

2 Answers2

2

Yes, include them using the Binary element.

<Binary Id='MyCustomActionBinary'
        SourceFile='$(var.CustomActionProject.TargetPath)' />

This will make them available to your CustomAction where you can use the BinaryKey attribute to reference the Binary:

<CustomAction Id='MyCustomAction'
              BinaryKey='MyCustomActionBinary'
              DllEntry='MyCustomFunction'
              Execute='deferred' />
caveman_dick
  • 6,302
  • 3
  • 34
  • 49
  • Sure, you can. But the infrastructure to get the blob made available, invoked and cleaned up is considerable. C#/DTF allows you to encapsulate all of this inside the custom action to simplify the story. – Christopher Painter Apr 08 '13 at 15:51
  • Actually, this is what I was looking for, perhaps I wasn't very clear: my purpose is to include an existing exe/dll - and call it during installation from wxs code (not from a CustomAction dll). – scrat.squirrel Apr 08 '13 at 15:53
  • @ChristopherPainter I currently am working on a project in which my project .exe file has several dependencies...where can I get more information on including project dependencies for a project .exe in a WiX bootstrapper? I reference the `ExePackage` for my project but it does not include its dependencies. –  May 23 '14 at 18:09
  • shall we use more than one dll ? – vijay Aug 04 '17 at 03:54
1

If you are using C#/DTF to write a custom action, you simply add the DLL's as references. For any other kind of file you add them to the project as Content | CopyAlways and the build will automatically include these files in the self extracting custom action. They will be available in the current directory ( a temp directory) when the CA runs and automatically cleaned up when the CA ends.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • sorry, maybe I'm not clear enough: I don't want to include these in the CustomAction.CA.dll, I want them included through the Product.wxs code. – scrat.squirrel Apr 08 '13 at 15:40
  • Why? Realize that you are just going to have to reinvent all that infrastructure if you do. If you are calling an EXE, you should probably be using the QuietExecCA. If you are calling a DLL, you should probably add it as a reference. Otherwise you have to write all the code to extract from the Binary table, use reflection to invoke it and then clean up. I'd have to have a very, very compelling reason to do all this instead of taking advantage of built-in functionality. – Christopher Painter Apr 08 '13 at 15:46
  • OK, I get it, then I won't call the external exe/dll from Custom Actions. I will only call them from wxs code. Thanks for the answer anyway, it clarified many things for me :) – scrat.squirrel Apr 08 '13 at 15:51
  • Sadly, it might be a little more complicated. Does the EXE you plan on calling have a DLL dependency? If so, you want to call them from a temp directory and not be installed? If so, it's a little more complicated. Let me know if that's your story. – Christopher Painter Apr 08 '13 at 16:00
  • No, the exe i want to call is just a command-line utility, it has no dependencies. – scrat.squirrel Apr 08 '13 at 16:03
  • Sorry, when you said you wanted to use it in a custom action and then said you wanted to write the custom action in C# I assumed you would want to write a DTF custom action and use Process.Start to call the EXE. Now it sounds like you just need the MSI to call the EXE directly. – Christopher Painter Apr 08 '13 at 16:09
  • yep, i was confused :)... now i updated the question, hopefully made it a bit more clear. – scrat.squirrel Apr 08 '13 at 16:11