Enterprise Framework

Software Solutions in the Enterprise

How To : NuGet Best Practices for Adding To New or Existing Projects

How To : NuGet Best Practices For Adding to New or Existing Projects

Keeping Nuget packages consistent in your solution is critical.  A lot of devs even now and days do it the hard way by going to the individual projects and trying to manage the Packages that way.  Managing NuGet packages in your solutions is easier than you think it is and will reduce headaches of DLL hell.

Packages in Source Control

  • DO NOT put NuGet packages into Source Control.  Exclude the Packages folder from the Solution root before checking in.  Whenever your solution is pulled fresh from source control, it will determine the packages don't exist and try to pull them down automatically if they are from the public NuGet servers.
  • DO NOT distribute packages with your code unless they are from your internal NuGet server and you are giving it to a client or something.
Using Visual Studio 2015

  • Right click the Solution > Choose Manage NuGet Packages for Solution.
  • Click Installed, this will show you all of the NuGet packages in the left column currently used by all projects in the solution.  The right column displays a list of the projects and the NuGet package version that is installed next to it.  
  • In the left column, choose a NuGet Package (Example:  Newtonsoft.Json)   
  • In the right column in the list of projects, you should scroll down and ensure that all the version numbers are the same across all projects, if they are not, you really should update them.  You can do this by putting a check next to the project with a older NuGet version.  Then in Version row, choose the one that matches the other projects in the solutions and click, 
NOTE:  Before updating packages you should finish any development work you are on before messing with NuGet Packages.  

  • DO NOT include the NuGet Packages folder in source control.  
  • DO NOT distribute NuGet Packages unless from internal NuGet server and you need to.
  • Use Manage NuGet Packages for solution to determine which NuGet packages and versions are being used across projects.  
  • Sync NuGet package versions across projects (Checkin Dev work before messing with Packages).

Pingbacks and trackbacks (1)+

Comments are closed