WiX: how to pack exe or dll to use only during installation

妖精的绣舞 提交于 2019-12-25 07:19:43

问题


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.


回答1:


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' />



回答2:


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.



来源:https://stackoverflow.com/questions/15883150/wix-how-to-pack-exe-or-dll-to-use-only-during-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!