1

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

4

1 回答 1

2

我以前遇到过这个问题。在阅读了 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,它将被拾取。

于 2016-10-11T15:16:54.717 回答