Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between References and Dependencies in Visual Studio 2017

When I create a new ASP.NET Web Application in Visual Studio 2017, I end up with a Solution Explorer containing a References element.

When I create a new ASP.NET Core Web Application in Visual Studio 2017, I end up with a Solution Explorer containing a Dependencies element. Furthermore in this situation, NuGet didn't create local packages folder.

Why this difference? Is it possible to have this same Dependencies element with the ASP.Net Web Application solution?

like image 466
Bronzato Avatar asked Feb 02 '19 18:02

Bronzato


2 Answers

Why this difference ?

They are basically no different, they are used to store and manage references. Just as Lex said, the Dependencies is a better way to represent different types of references, we can clearly know where the reference comes from, SDK, nuget, etc. so that we can manage our references more efficiently.

See the info from Introduction to ASP.NET Core:

ASP.NET Core is a redesign of ASP.NET 4.x, with architectural changes that result in a leaner, more modular framework.

.

Is it possible to have this same Dependencies element with the ASP.Net Web Application solution ?

Since there is still a bunch of open issues on GitHub regarding support of new csproj format for ASP.NET (non-Core) applications. We could not change the ASP.Net Web Application to the new project type, we could not have the same Dependencies element with the ASP.Net Web Application.

But if you are interested, you could check this thread for how to convert to the new project type.

Hope this helps.

like image 60
Leo Liu-MSFT Avatar answered Sep 28 '22 04:09

Leo Liu-MSFT


Display difference:

The way you see your projects in the Solution Explorer depends on the format of their .csproj file. In the old format (xml 2003 or similar) you have a References sub-tree, where every project reference, package dependency, system framework reference and third-party libraries are shown.

In the new format, you have a Dependencies sub-tree, which in turn has a sub-tree for every different type of dependency.

There are some differences as to how the two are implemented, but in general the only big difference (if you are not going into .csproj files and such) is how they are shown in the Solution Explorer.

Note that this display is project dependent, so you can have different displays for different projects in the same solution.

NuGet packages:

The difference in the usage and restoration of your NuGet packages comes from the following. The old format uses packages.config configuration by default, which means that every project holds all the packages in needs in a local cache. On the other hand, the new format uses Package Reference configuration by default, where all the packages in the solution are restored to a central cache in the user directory (usually at %user%/.nuget/packages).

like image 30
Josef Ginerman Avatar answered Sep 28 '22 03:09

Josef Ginerman