Friday, January 18, 2013

NuGet Circular Dependencies

Being heavy users of NuGet, here at the office we are frequently annoyed at the seemingly poor quality of the implementation. Between ridiculous performance (mainly of the local NuGet server), random breakages, and insane error messages, we spend far too much time managing the package manager instead of doing our jobs.

One of the most annoying errors we've encountered is when it claims to have detected a circular reference. This usually goes something like this:

Our Package #1 => Third Party Package #1 => Third Party Package #2 => Our Package #2 => Our Package #1

Good golly! It's a circular reference! No, wait... why is it that some random package off the internet depends on our own internal package? That's crazy talk.

We've seen two problems that can cause this madness.

1. NuGet is trying to install a dependency but the package for the dependency is not on the NuGet server. (This case has been confirmed.)

2. A package is missing from packages.config because NuGet randomly removed it at some point in the past. This again follows on the theme of the missing dependency. (We weren't as certain as to whether this was the exact cause because of related activity, but this is our best theory.)

If the NuGet folk happen to be reading this, regarding the performance of the local server I'd suggest caching the directory traversal to limit the IO activity during the query process. When you get lots of packages the IO to read them repeatedly during the use of the IQuerable seems significant. I'm sure I could go on and on about all the strange problems we've had, but I need to do some actual work, so I'll sign off now.

Hopefully this post saves a few hairs from being pulled out for somebody else out there.

No comments: