Skip to content

New Project NuGet Packages Install

This blog is as much to remind me as anything else but here goes. A common problem I have when developing .NET solutions is dealing with NuGet packages, and one particular scenario is where I’m working in a solution and need to add a new project. When doing this I often want to use a number of packages I’ve been using elsewhere in the code, but I don’t want to have to add each one individually. I found this great blog, which provides a number of useful commands, one of which is a solution to the problem. First of all add a new packages.config to the newly created project and then copy your NuGet references into it, like the example below:

<?xml version="1.0" encoding="utf-8"?>
  <package id="Autofac" version="3.5.2" targetFramework="net46" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net46" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net46" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net46" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net46" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net46" />
  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net46" />
  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net46" />
  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net46" />

Once that is done and saved open the package manager console and type the following:

update-package -projectname <myNewProjectName> -reinstall

This will go off and get all the related packages and add the references to your project so you should be up and running quickly, hopefully someone will find it useful.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *