c# - WIX 自定义操作 : use dllimport

标签 c# c++ wix windows-installer dtf

我有一个 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/

相关文章:

c# - 在 C# (VTSO) 中将 Excel FitToPagesWide 设置为 "Automatic"

c# - 通过 for 循环将一个 XML 文件插入到另一个文件中 (XDocument)

c++ - 如何执行多次调用的函数,只调用一次!

windows-7 - 如何将文件复制到 CommonAppDataFolder?

wix - WiX中TARGETDIR和INSTALLDIR的用法是什么?

wix - wix 可以提示输入 Windows 服务用户名/密码吗?

c# - 系统.MethodAccessException : Attempt by security transparent method to access security critical method fails on all applications

c# - 为什么编译器无法推断对象数组类型?

c++ - friend 说明符如何在 C++ 中工作?

c++ - 如何模拟不存在的 find_first_not_of 函数?