Mike Eason
Mike Eason

Reputation: 9723

Project Nuget Depdendency Hell

I have a problem with projects that depend on NuGet packages that they do not consume, or indirectly require dependencies, here is the project structure:

- Data        -> Depends on Entity Framework
- Business
- UI

The problem here is that because Data has a dependency to Entity Framework, this means that the Business layer and also the UI must also install this in their projects.

How can I separate these dependencies so that only the Data layer requires Entity Framework?

Upvotes: 2

Views: 511

Answers (1)

KarmaEDV
KarmaEDV

Reputation: 1691

This shouldn't be the case. Make sure of the follow points:

  • Make sure your references are set correctly. If you have Resharper (even just the Trial) use the "Optimize References" Command on every project. If you can use it (depends on the VS SKU), generate a Dependency Graph and have a look at it.

enter image description here enter image description here

  • Once the references are cleaned up, go to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution -> Installed packages -> Button "Manage" and make sure you untick the projects where you don't need your dependencies. Nuget will install/uninstall accordingly.

enter image description here

  • I suggest you enable Manage NuGet Packages for Solution with a right-click on the solution and follow these instructions if you don't want to check-in Nuget-DLLs into your TFS/SourceControl

enter image description here

  • If you did it correctly, the minimal version of the dependency graph will look like this

enter image description here

Upvotes: 2

Related Questions