C#项目中的C++ nuget包使用

C++ nuget package usage in C# project

在 C# 项目中,我想通过 nuget 包管理器来使用 C++ .dll。这可能吗?如何?一个示例项目将不胜感激。

cppTestLIB.dll使用CoApp打包(http://coapp.org/)

当我从 C# 项目安装这个包时,出现以下错误。

Could not install package 'cppTestLIB 1.0.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

我通过不将非 .NET DLL 放入 lib 文件夹解决了我的问题。我没有使用过 CoApp 工具。

只需在 .nuspec 文件中添加这样一行,

  <file src="native.dll" target="binaries\native.dll" />

c++ dll被打包,可以从C#项目中使用。