Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget Dependencies in .NET Core

If I install some Nuget package Package1, it is added to Dependencies/Packages/Package1. When I install another Nuget package Package2 which has dependency to Package1, there will be added Dependencies/Packages/Package2/Package1.

In this case I have right now this:

Dependencies
|_Packages
  |_Package1
  |_Package2
    |_Package1

There is duplicity of the Package1. Should I remove the Dependencies/Packages/Packages1, or is it ok like this? Isn't it takes more space?

like image 939
Banana Cake Avatar asked Oct 18 '25 15:10

Banana Cake


2 Answers

It's fine, assuming both your direct dependency and the indirect one use the same major version. If they have different major versions, you could be in trouble, as they may well be incompatible. (This is a weakness in .NET versioning at the moment, IMO.)

You can remove the direct dependency if you want - unless you want a later version than Package2 depends on. For example, if Package2 depends on Package1 version 1.2.0, but you want something that's only in Package1 version 1.5.0, it's fine for you to state that dependency explicitly. Only one version of Package1 will end up being deployed.

like image 110
Jon Skeet Avatar answered Oct 20 '25 05:10

Jon Skeet


This user-interface feature isn't showing you files on disk. It's a logical hierarchy of dependencies and Nuget doesn't store downloaded packages like this physically. You can't "remove" them because the UI is showing you a statement of fact - this package does depend on these other packages.

(It took me a while to understand what you were asking because I was looking for this structure on disk, and could not reproduce this.)

like image 34
Tom W Avatar answered Oct 20 '25 03:10

Tom W