Redefine where NuGet packages get installed
Jul 31, 2013 · 1 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.
Here was my root source control folder before making any changes.
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"?> <settings> <repositoryPath>..Library</repositoryPath> </settings>
Your project folder should now look like this;
Now to finish the job, you must do the following for each project;
- Open the project
- Uninstall all the packages (ensuring all the references are removed)
- Delete the bin directory
- Delete the original packages folder
- Re-add each package
- Save and build
I hope you find this useful, doing this has certainly tidied up my Team Foundation Server (TFS).
Related PostsEdit this page on GitHub
About the author
I am Jon Preece, an experienced full stack website and software developer from Warrington (UK) currently working in and around Manchester (UK).
Throughout my 10+ year professional career I have worked in many sectors, including; e-commerce, financial services, marketing, healthcare, travel and accountancy.
I love to teach, I love to learn and share my knowledge with others, I love to speak at public events.