NuGet and multiple solutions

Code Silverback picture Code Silverback · Sep 15, 2011 · Viewed 11.1k times · Source

We have two solutions: foo.sln and bar.sln

I have a common library that is used by both foo and bar. Common.csproj is used by both.

If I open foo and update nuget references, all references in Common.csproj point to foo/packages/. If I later open bar and update nuget references, all references get set to those in bar/packages/. Naturally, this pisses off the foo team as it can cause incompatibilities between Common.csproj and Foo-specific stuff like Foo.Data.csproj, which still points to foo/packages.

There must be some obvious solution other than: "create a huge solution that contains all your projects, and if you need to touch nuget, only do it from that solution."

There seems to be an issue on codeplex, (the top voted issue, incidentally), but evidently I'm too thick to understand how this issue is resolved. Can someone explain how to fix this?

Answer

Daniel Dyson picture Daniel Dyson · Sep 22, 2011

This problem preceeds NuGet. If you have a project referenced in two solutions, and change assembly references in the project when it is open in one solution, of course it will change the reference path for that project when it is open in the other solution. This has always been the case, regardless of how the reference was changed (with NuGet or otherwise).

But the real problem is that when you do an update, the updated packages do not appear in the foo/packages directory right?

The simple solution is to move Common.csproj into a solution of its own, with its own references, packages folder, build and release process. Then create a NuGet package of your own with any relevant dependencies built into it. Then you can install your Common package into both Foo and Bar and then the Foo team is free to update to the latest version of Common as and when they are ready.

The main argument that I have heard against this is that you might want to step through the Common code while debugging, but this is no longer an issue with Visual Studio 2010.

The fundamental question you need to ask is who owns Common.csproj? Is it the Foo team or the Bar team?