.Net Core项目不断引用其他项目,而不是同名的Nuget包 [英] .Net Core project keeps referencing other project instead of Nuget package of same name

查看:216
本文介绍了.Net Core项目不断引用其他项目,而不是同名的Nuget包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎遇到了与这个未解决的问题相同的问题。

I seem to be having the same problem as this unanswered question.


注意:通常,我会避免重新发布,但是缺少答案和低流量似乎需要刷新SO提要。

NOTE: Ordinarily, I'd avoid the repost, but the lack of an answer and the low traffic seemed to warrant a refresh into the SO feed.



设置



The setup


  1. 创建两个.Net Core项目( A B )放在同一文件夹中的两个单独解决方案中。在 A 中创建一个Nuget程序包。 (您可以将其上传到Nuget,MyGet,或仅保存在本地。只需确保已配置源。)

  1. Create two .Net Core projects (A & B) in two separate solutions in the same folder. From A, create a Nuget package. (You can upload it to Nuget, MyGet, or just keep locally. Just make sure the source is configured.)

B ,添加Nuget程序包。

In B, add the Nuget package.



结果



项目 A 现在已添加到项目 B 的解决方案中。

The result

Project A has now been added to the solution for Project B.


  1. 为什么会这样?

  2. 我如何使VS识别它应该引用Nuget包,而不是该项目?



其他内容



我正在运行VS 2015 Pro在Windows 10上更新3。

Other stuff

I'm running VS 2015 Pro Update 3 on Windows 10.

在我的实际情况中,我的Nuget软件包是更高版本。当打开 project.json 文件时,在 ProjectA 依赖项上收到编译器警告,提示我依赖版本1.1,但版本找到1.0。

In my real scenario, my Nuget package is at a later version. When I open the project.json file, I get a compiler warning on the ProjectA dependency that says I'm depending on version 1.1, but version 1.0 is found.

我创建了关于GitHub 供您使用。

推荐答案

您必须将解决方案作为.NET Core项目放置在单独的目录中在VS2015中有独特的文件系统要求,当您将它们放在同一目录中时,其性能会很差(每种解决方案都会生成一个隐藏的 .vs 文件夹,并且最终会重叠)。

You must place the solutions into separate directories as .NET Core Projects in VS2015 has unique file system requirements, and will behave poorly when you put them in the same directory (each solution will generate a hidden .vs folder, and they will end up overlapping).

例如,您可以将目录结构更改为:

For example you could change the directory structure to this:

.\Solutions\A\ <-- Directory for Solution A
.\Solutions\B\ <-- Directory for Solution B
.\A\ <-- Project A
.\B\ <-- Project B

这将意味着每个解决方案的隐藏 .vs 文件夹将不再重叠(即,解决方案不共享此文件夹)

This would mean that the hidden .vs folders for each solution will no longer overlap (ie, the solutions do not share this)

.\Solutions\A\ProjectA.sln
.\Solutions\A\global.json
.\Solutions\A\.vs\

.\Solutions\B\ProjectB.sln
.\Solutions\B\global.json
.\Solutions\B\.vs\

这篇关于.Net Core项目不断引用其他项目,而不是同名的Nuget包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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