In Visual Studio, storing packages at the solution level has unfortunate consequences

Topics: General
May 16, 2014 at 7:49 PM
I've been using NuGet in VS2010, VS2012, and now with VS2013. In all of these, when "Manage NuGet Packages" downloads a package as it installs it into a project, it stores the files in a subdirectory of the solution (named "packages"), rather than as a subdirectory of the project.

The normal structure, in VS, is to have a directory containing a solution file and a number of project subdirectories, each of which contains a project file and assorted source files.

NuGet packages are installed into projects, but the files that are downloaded to support a package are stored at the solution level.

This causes problems when a project directory is included in more than one solution. We, for example, have a number of shared libraries that are used in multiple projects. In some cases, we simply reference specific versions of a library's DLL, and there's no issue. But in some projects, we need to be able to develop both the parent application and the dependent library in an integrated manner.

What we do, in this case, is to checkout the project directory of the dependent library into the solution directory, at the same level as the projects that are included in that solution directly.

What happens, when we install a NuGet package into a project that is shared in this way is that in every solution other than the one in we had done the the install, the project uses the package, but the package doesn't exist.

I've found no way to resolve this other than by uninstalling and then re-installing the package. That makes me nervous. And while the builds seem to work OK, I get a warning that also makes me nervous:
All projects referencing aardvark.csproj must install nuget package Microsoft.Bcl.Build. For more information, see
Now I understand that what we're doing may seem a bit odd, but it's not really that unusual.

I can see a couple of enhancements that might make this work better:
  • provide an option to store the NuGet packages in the project that they're being installed in, rather than in the solution, or
  • provide a "reinstall" option, in the NuGet package manager, that would copy the needed package into the solution, without modifying the project in question.
I'm not, though, sure I understand all the possible consequences of either.

So I thought I'd throw it open for discussion.