问题描述
我正在尝试找出处理这种情况的最佳方法.
I'm trying to figure out what the best way to handle this scenario is.
假设我有一个库,它被多个不同的非相关解决方案引用,我们称之为 WebServiceInterface.dll.这个库依赖于 JSON.NET.
Let's say I have a library that's referenced by multiple different non-related solutions, let's call it WebServiceInterface.dll. This library has a dependency on JSON.NET.
在 NuGet 之前
JSON.NET 二进制文件是通过 WebServiceInterface 项目中的 SVN 外部引用的.其他依赖于 WebServiceInterface 的解决方案引用了该项目(也作为 SVN 外部),因此拉取了项目及其依赖项.
The JSON.NET binary was referenced via a SVN external in the WebServiceInterface project. Other solutions which had a dependency on WebServiceInterface referenced the project (also as an SVN external) and as a result pulled both the project, and it's dependencies.
使用 NuGet
我还没有弄清楚如何强制将 JSON.NET 引用存储在 WebServiceInterface 项目下(而不是 RandomSolutionpackages 位置).我找到了对项目级和解决方案级包的引用 @ nu-get,但是当我通过 nu-get 添加依赖项时,我似乎无法找到如何指定它.
I haven't figured out how to force the JSON.NET reference to be stored under the WebServiceInterface project (as opposed to the RandomSolutionpackages location). I found reference @ nu-get to project-level and solution-level pacakges, but I can't seem to find out how to specify this when I add a dependency via nu-get.
这里的目标是,当有人签出 WebServiceInterface 并将其添加到它构建的新解决方案中时(而不是破坏对 JSON.NET 的引用,该引用指向最后一个签入解决方案下的包目录).
The goal here is that when someone checks out WebServiceInterface and adds it to a new solution that it builds (instead of having broken references to JSON.NET which point to the packages directory under whatever the last solution was that checked in).
推荐答案
包总是存储在解决方案级别,所以如果你将一个包安装到多个项目中,它们来自同一个地方.我不相信你可以配置它,让每个项目都有自己的包文件夹.
The packages are always stored at the solution level, so if you install a package into multiple projects, they came from the same place. I don't believe you can configure it so that each project has its own packages folder.
我不确定有没有一种很好的方法来做你正在尝试的事情.你可能有一个 在获取包的项目上构建步骤,但我不知道这是否适合您.
I'm not sure there's a nice way to do what you're trying. You could maybe have a build step on the project that fetches the package, but I don't know how well that will suit you.
我建议在 NuGet 问题跟踪器 中发帖进行讨论.致力于它的人似乎很活跃,所以他们可能会在未来的版本中添加支持:-)
I'd recommend posting in the NuGet Issue Tracker to get a discussion going. The people working on it seem pretty active, so it might be something they can add support for in a future version :-)
这篇关于Nu-Get &多个解决方案引用的项目的项目级别依赖性问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!