C# – Managing in-house NuGet packages with source code access

cclosed-sourcenugetsource code

We have a lot of in-house libraries that we would like to share between projects inside the company. These are some of the requirements:

  • library sources are stored in repositories separated from end-projects
  • end-projects include libraries via NuGet
  • it must be possible to easily inspect the source code for any given libary while working on an end-project

Setting up our private NuGet repository isn't a problem, but managing sources is. We tried to expose the sources via source server and it kinda works, but not quite: VS downloads the sources while debugging external code, but not when you try to navigate to definition/implementation. Basically, you can only go to source code when debugging, which is not quite what we need.

So, the questions are:

  • what ways exist to provide access to source code of internal libraries without the need to having the code in the same repo/solution
  • is there a way to set up the Symbol server/NuGet feed combo so that VS uses the symbols for navigation, not just for debugging?

Using ReSharper/other add-ins is an option.

Best Answer

What should work is simply checking out the source code for the NuGet package and opening the solution in a separate instance of Visual Studio.

Visual Studio has a neat trick of switching between code in open instances by working out what you have referenced. The first time this happened to me whilst I was debugging, was a revelation.

The main problem you face is making sure the checked out code for the dependent package represents the same version as your NuGet reference in the main project. Not a problem if you follow a policy of always building against the most recent version of your package.

Another benefit of this approach is that if the package needs to change, you can make the change there and then.

Related Topic