我有一个WiX安装程序和“自定义操作”项目。我添加了C#库作为对“自定义操作”项目的引用。此C#dll使用DllImport到一个C++ dll。安装时出现错误:无法加载DLL mycpp.dll:找不到指定的模块。我将mycpp.dll添加到CA项目,并尝试使用属性:嵌入式资源,复制到输出目录-但没有结果。如何使安装程序找到mycpp.dll

最佳答案

我以前有过这个问题。仔细阅读wix的MSBuild文件之后,我最终找到了一个属性,该属性用作包含自定义操作dll的自解压程序包中所需dll的列表。

在wix.ca.targets中(在sdk文件夹中),有一个名为CustomActionContents的属性,在运行makefxca时使用。

这是这套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.
==================================================================================================
-->


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

因此,看起来您可以将对mycpp.dll的引用标记为本地副本,它将被自动提取,或者您可以在自定义操作项目中添加新属性(可能是编辑csproj并添加该属性),其中包含路径到DLL,它将被拾取。

关于c# - WIX自定义操作:使用dllimport,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39972891/

10-13 07:10
查看更多