简体   繁体   中英

Nuget package referenced in 2 assemblies does not work

I have a solution that is built like that:

ProjectA -> Assembly2 -> Assembly1 -> NuGet Package (Newtonsoft.JSON)

I'm currently developing on Assembly2, which has a dependency to Assembly1. I debug with ProjectA. So long, the Newtonsoft.dll is copied to my bin folder, and everything works.

Now I want to use Newtonsoft directly in my Assembly2, so I added it as NuGet Package. After that, the Newtonsoft.dll is no longer copied to the bin folder.

I tried to download the Newtonsoft.dll directly (or use the Newtonsoft.dll from Assembly1 directly via 'Browse...'). This works, too. It seems, that this problems only occur, when I use NuGet in Assembly2. Can someone explain this behaviour?

I used the exact same Version of Newtonsoft.

Puzzling for sure. From your description that ought to be fine, but...

"Transitive dependencies" are your friend. If assy1 references NS.Json, and assy2 refs assy1, then NS.Json is available to assy2. There is no need to ref NS.Json from assy2.

This is a-good-thing. It means that some versioning hell is removed. If you want to upgrade NS.Json then you only have 1 place to do that. The ref is not scattered all over your projects. This works well if you also follow the good practice of having a "clean" dependency graph.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM