【发布时间】:2019-04-15 14:51:39
【问题描述】:
我有一个与第三方本地 DLL 接口的 C++/CLI DLL。我想把它打包成 Nuget。
我关注了this official MS guide、this blog post 和read through this other question。
这就是我所做的:
首先,我创建了正确的 nuspec 文件:
<?xml version="1.0"?>
<package >
<metadata>
<id>CPlusPlusNativeIFace</id>
<version>1.0.4</version>
<title>CPlusPlusNativeIFace</title>
<authors>Jens Rabe</authors>
<owners>Who owns that</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A DLL that makes a native third-party DLL available to .net</description>
<releaseNotes>foo</releaseNotes>
<copyright>errm...</copyright>
<tags>foo bar</tags>
</metadata>
<files>
<file src="..\Release\**" target="runtimes/win-x86/lib/net461" />
<file src="..\x64\Release\**" target="runtimes/win-x64/lib/net461" />
<file src="DummyAny\**" target="ref\net461" />
</files>
</package>
然后我为 Release x86 和 Release X64 编译了 DLL。然后我创建了DummyAny 文件夹,将x86 的内容复制到其中,并使用链接2 和3 中的corflags 实用程序去除32 位标志。
当我现在 nuget pack 和 nuget add 并尝试在另一个项目中引用该包时,我总是得到:
Could not install package 'CPlusPlusNativeIFace 1.0.4'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', 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.
我仔细检查了文件是否正确:
- 我在
runtimes/win-x86/lib/net461中有 x86 的东西 - 我在
runtimes/win-x64/lib/net461中有 x64 的东西 - 我有一个
ref/net461文件夹,其中包含被操纵的 dll
但我仍然无法加载包。
我还尝试将 CPU 特定的 DLL 放入 runtimes/win-x86/native 和 runtimes/win-x64/native 中,但无济于事。
我还缺少什么?这不适用于基于 .net Framework 构建的 C++/CLI 项目吗?
【问题讨论】:
标签: nuget