我怎样才能让我的管理的NuGet包支持C ++ / CLI的项目? [英] How can I make my managed NuGet package support C++/CLI projects?

查看:2072
本文介绍了我怎样才能让我的管理的NuGet包支持C ++ / CLI的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了的NuGet包,效果很好,当我使用它从一个C#项目。它包含在的lib / net40 目录下的DLL,而该DLL被添加作为参考。

I have made a NuGet package that works well when I use it from a C# project. It contains a DLL in the lib/net40 directory, and the DLL gets added as a reference.

现在的NuGet支持C ++,实际上,我怎么修改我的包,这样的DLL可以添加在C ++ / CLI项目管理的参考?我找不到任何教程说明这一点。如果我尝试刚才添加的包作为是,我得到以下错误:

Now that NuGet supports C++, how do I actually modify my package so that the DLL can be added as a managed reference in a C++/CLI project? I can't find any tutorials explaining this. If I try to just add the package as is, I get the following error:

您要安装这个包到该目标的原生版本= V0.0,但包不包含与该框架兼容的任何程序集引用或内容文件的项目。

You are trying to install this package into a project that targets 'Native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework.

有人会认为,解决的办法是把文件下的lib /人,但根据<一个href="http://docs.nuget.org/docs/reference/support-for-native-projects">http://docs.nuget.org/docs/reference/support-for-native-projects,不支持。此外,只需把DLL直接lib下似乎并没有做任何事情。

One would think that the solution is to put the files under lib/native, but according to http://docs.nuget.org/docs/reference/support-for-native-projects, that is not supported. Also, simply putting the DLL directly under lib doesn't seem to do anything.

显然,我应该用做一个 .props .targets 下构建/本机文件,但我需要什么投入这些文件,使这项工作?

Apparently, I am supposed to do this with a .props or .targets file under build/native, but what do I need to put into those files to make this work ?

推荐答案

正如在回答这个端口(<一href="http://stackoverflow.com/questions/23571241/nuget-wont-install-entity-framework-into-c-cli-project">Nuget不会安装实体框架为C ++ / CLI项目)的NuGet不会使更改为C ++ / CLI的项目给你。它还是会下载并解包的依赖你。我们用它在命令行作为我们的化妆依赖的一部分。命令行看起来是这样的:

As mentioned in the answer to this port (Nuget won't install Entity Framework into C++/CLI project), NuGet will not make the changes to a C++/CLI project for you. It will however download and unpackage the dependency for you. We use it from the command line as part of our make dependencies. The command line will look something like this:

/.NuGet/NuGet.exe
      Install 
      -NonInteractive 
      -ConfigFile $ENV{SRC_ROOT}/.nuget/NuGet.config 
      -OutputDirectory $ENV{SRC_ROOT}/packages 
      $ENV{SRC_ROOT}/packages.config

请注意在命令行areguments分开一个行,使阅读更加容易。此外,我们决定检查的NuGet到我们的源代码控制联合国的.NuGet文件夹。我们的目标是使之更容易安装在构建机为各种环境下(并非所有这些使用Visual Studio)。一旦你的第一次运行这个命令,你必须手动添加依赖关系到你的C ++ / CLI项目。
希望有所帮助。

Note that the command line areguments are separated one to a line to make reading easier. Also we decided to check NuGet into our source control un the .NuGet folder. The goal was to make it easier to setup a build machine for our various environments (not all of which use Visual Studio). Once you have run this command for the first time, you must manually add the dependencies to your C++/CLI project.
Hope that helps.

这篇关于我怎样才能让我的管理的NuGet包支持C ++ / CLI的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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