如何共享的C#的NuGet依赖项添加到C ++ / CLI的项目吗?项目、NuGet、CLI

2023-09-03 03:25:06 作者:不准哭

环境:Visual Studio解决方案有2个组件,Cs和.cpp的。

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#项目。我用由作者所提供的原包装。将它们添加到铯项目工作正常,但不是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的项目,只需添加一个参考(菜单 - >引用 - >添加新参考 - > Browse->浏览...)到nlog.dll说的NuGet下载到您的[solutionfolder] /包/ n日志...文件夹。 这似乎为我工作。

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.