如何将共享的 C# NuGet 依赖项添加到 C++/Cli 项目? [英] How to add shared C# NuGet dependencies to a C++/Cli project?

查看:26
本文介绍了如何将共享的 C# NuGet 依赖项添加到 C++/Cli 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:具有 2 个程序集 Cs 和 Cpp 的 Visual Studio 解决方案.

Context: A Visual Studio solution with 2 assemblies, Cs and Cpp.

  • Cs 是一个 C#/.net45 dll
  • Cpp是一个C++/Cli dll,一个用/clr编译的C++ dll.

我有一些依赖项是来自 nuget.org 的纯 C# 项目.我使用作者提供的原始软件包.将它们添加到 Cs 项目可以正常工作,但不能添加到 Cpp.

I have some dependencies that are pure C# projects from nuget.org. I use the original packages provided by the authors. Adding them to the Cs project works fine, but not to Cpp.

如何将 C# 包添加到 C++ 项目中?

How can I add the C# package to the C++ project?

由于它是 C++/Cli,我可以轻松使用 .net 对象,并且我使用例如在 C# 库中的 C++ 库中.但不知何故,nuget 只允许我选择 C# 项目来添加 C# 依赖项,而不是 C++/clr 项目.

Since it's C++/Cli, I can easily use .net objects, and I use e.g. in the C++ library stuff from the C# library. But somehow nuget only allows me to select C# projects to add a C# dependency to, not C++ /clr ones.

推荐答案

在您的 C++/CLI 项目中,只需添加一个引用 (Menu->References->Add New Reference->Browse->Browse...) 到nuget 下载到您的 [solutionfolder]/packages/nlog... 文件夹的 nlog.dll.这似乎对我有用.

In your C++/CLI project, just add a reference (Menu->References->Add New Reference->Browse->Browse...) to the nlog.dll that nuget downloads to your [solutionfolder]/packages/nlog... folder. That seems to work for me.

这篇关于如何将共享的 C# NuGet 依赖项添加到 C++/Cli 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆