简体   繁体   English

WIX自定义操作:使用dllimport

[英]WIX custom action: use dllimport

I have a WiX installer and Custom Actions project. 我有一个WiX安装程序和“自定义操作”项目。 I added C# library as reference to Custom action's project. 我添加了C#库作为对“自定义操作”项目的引用。 This C# dll uses DllImport to one C++ dll. 此C#dll使用DllImport到一个C ++ dll。 When installing I receive error: cannot load DLL mycpp.dll : specified module not found. 安装时收到错误消息:无法加载DLL mycpp.dll :找不到指定的模块。 I added mycpp.dll to CA project and tried using properties : embedded resource, copy to output directory - but no result. 我将mycpp.dll添加到CA项目,并尝试使用属性:嵌入资源,复制到输出目录-但没有结果。 How can I make my installer find mycpp.dll ? 如何使我的安装程序找到mycpp.dll

I've had this issue before. 我以前有过这个问题。 After reading through the MSBuild files for wix I eventually found a property that is used as a list for the dlls needed in the self-extracting package that contains the custom action dll. 仔细阅读wix的MSBuild文件后,我最终找到了一个属性,该属性用作包含自定义操作dll的自解压程序包中所需dll的列表。

in wix.ca.targets (in the sdk folder) there is a property called CustomActionContents that is used when running makesfxca. 在wix.ca.targets中(在sdk文件夹中),有一个名为CustomActionContents的属性,在运行makefxca时使用。

Here's the comment for this set of msbuild targets which package your custom action dll. 这是这套msbuild目标的注释,这些目标打包了您的自定义操作dll。

<!--
==================================================================================================
PackCustomAction

Creates an MSI managed custom action package that includes the custom action assembly,
local assembly dependencies, and project content files.

[IN]
@(IntermediateAssembly) - Managed custom action assembly.
@(Content) - Project items of type Content will be included in the package.
$(CustomActionContents) - Optional space-delimited list of additional files to include.

[OUT]
$(IntermediateOutputPath)$(TargetCAFileName) - Managed custom action package with unmanaged stub.
==================================================================================================
-->

and

<!--
Items to include in the CA package:
 - Reference assemblies marked CopyLocal
 - Project items of type Content
 - Additional items in the CustomActionContents property
-->

So it looks like you can mark your reference to the mycpp.dll as copy local and it will be automatically picked up or you can add a new property in your custom action project (probably edit the csproj and add the property) which contains the path to the dll and it will get picked up. 因此,看起来您可以将对mycpp.dll的引用标记为本地副本,它将被自动提取,或者您可以在自定义操作项目中添加新属性(可能是编辑csproj并添加该属性),其中包含路径到dll,它将被拾取。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM