我有一个 WiX 安装程序和自定义操作项目。我添加了 C# 库作为自定义操作项目的引用。此 C# dll 使用 DllImport 到一个 C++ dll。安装时我收到错误:无法加载 DLL mycpp.dll
:找不到指定的模块。我将 mycpp.dll
添加到 CA 项目并尝试使用属性:嵌入资源,复制到输出目录 - 但没有结果。如何让我的安装程序找到 mycpp.dll
?
最佳答案
我以前遇到过这个问题。在阅读了 wix 的 MSBuild 文件后,我最终找到了一个属性,该属性用作包含自定义操作 dll 的自解压包中所需的 dll 的列表。
在 wix.ca.targets(在 sdk 文件夹中)有一个名为 CustomActionContents 的属性,在运行 makesfxca 时会用到。
这是对打包您的自定义操作 dll 的这组 msbuild 目标的注释。
<!--
==================================================================================================
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 自定义操作 : use dllimport,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39972891/