Jon Preece

Follow on TwitterJon Preece
Published on Jul 31, 2013 ยท 2 minute read.

If, like me, you are working on multiple projects that reference the same packages (StructureMap is a great example) you may have noticed that each project has its own version of each package. In this bite sized post, we will look at how to redefine where your packages get installed.

Root source control folder

Here was my root source control folder before making any changes.

TFS Root Folder
TFS Root Folder

When I dive into each folder, I see a packages folder, which contains each of my packages. Generally I use the same packages across multiple projects. What I would like is to be able to create a folder at the root level, called Library and place all my packages in there. Achieving this takes a bit of effort at first, but will pay off in no time. Go ahead and create the Library folder at the root level. Then for each project, go into the project folder and add a new file called NuGet.config. The contents of NuGet.config should match as follows;

<?xml version="1.0" encoding="utf-8"?>

Your project folder should now look like this;

NuGet Config File
NuGet Config File

The painful bit

Now to finish the job, you must do the following for each project;

  1. Open the project
  2. Uninstall all the packages (ensuring all the references are removed)
  3. Delete the bin directory
  4. Delete the original packages folder
  5. Re-add each package
  6. Save and build

I hope you find this useful, doing this has certainly tidied up my Team Foundation Server (TFS).

Visual Studio

Jon Preece

About the author

I am Jon Preece, an experienced website and software developer from the United Kingdom, based in Manchester.

Throughout my 10+ year professional career I have worked in many sectors, including; e-commerce, financial services, marketing, healthcare, travel and accountancy. Get in touch via Twitter.