Member-only story

Using configuration files to manage NuGet package versions (and other stuff!)

Russell Hammett Jr. (Kritner)
3 min readOct 10, 2018

--

NuGet.org, microsoft search results

Have you ever had a LOT of projects in a solution, many of which use the same NuGet packages? Managing package versions could be a nightmare!

Working with .net core, this was very much what I was dealing with. It got quite tedious to manage NuGet package versions across 20+ projects, especially when .net core was pre 1.0 release, when you were having new packages available sometimes multiple times a day! How can one manage all these package version and keep them in sync?

For a while, I didn’t really know what to search for, and I think my issue was I was being too specific in my search terms.

The answer, at least one of them, lies in a solution wide variables file Directory.Build.props (documentation here). In this file you can specify things like variables, and other “pieces” that should be present in csproj files at and deeper than the directory where the Directory.Build.props file is contained. Additionally, this file works in an “inheritance” sort of manner in that “deeper” Directory.Build.props files are able to override properties set in “higher” files.

As far as the NuGet packages are concerned, here’s a sample demo…

Starting with a project with three “empty” class library projects:

--

--

Russell Hammett Jr. (Kritner)
Russell Hammett Jr. (Kritner)

Written by Russell Hammett Jr. (Kritner)

Just a boring Application Developer/Dad. I enjoy gaming, learning new technologies, reading, and potentially other stuff. That’s about it.

No responses yet