Nuget is the visual studio plugin that allows you to download and install the libraries directly into your solution. It’s another adapted technology by Microsoft to save the time for searching and installing libraries in your projects. If you’re not aware about the Nuget then visit Nuget.org.
Why should I know about Nuget?
For example if you are using entity framework in your project in Visual studio 2012 then you’ll notice when you add the Ado.net Entity Data Model then your project will take little time to get the latest release of Entity framework through nuget. Then in your solution directory you’ll find a Packages folder and a package.config file added in your project. Similary, there are many projects who are hosted on Nuget server ready for download, install and use in your projects. For e.g. MVC scaffolding, Log4Net, Rhino mocks, JQuery, Json.NET, Castle Windsor etc. and lot many more.
So if you’re on VS2010 or earlier version just get the VS plugin available for your version of visual studio and get ready to have all these libraries to install in your project.
Should I check in the Packages folder in the Source Control to make them available for peers?
Answer is “NO”. You should not checkin packages folders as this will increase the size of repository and become overhead when taking latest (as the packages folder have size in MBs).
Now if you want to have your installed libraries available to all the peers then here’s the tip that should use to make the overcome the burden of putting packages into the source control repository.
Install the Nuget package manager:
If you’re connected to internet you can download the nuget package manager from Online gallery from Tools -> Extension Manager
In the Extension Manager dialog box, select the Online Gallery tab, and enter "nuget" in the search box to find the NuGet Package Manager extension.
Select NuGet Package Manager and then click Download.
If you want to download the nuget packages installer separately then it’s available on Visual Studio Gallery.
Download and install your desired package/library from Nuget.
Now before proceeding for checkin you must enable the setting for restoring the missing packages from visual studio 2012.
This will add following files in your solution.
Finally it’ll add the following setting in the Nuget.Config file that will prevent the packages to be added into the source control.
Here’s the complete documentation for above steps.
Note: This setting will instruct the MSBUILD to download the files before building the project. But there’s another option you need to enable to get the packages restored while building.
Go to Tools -> Options -> Package manager
And check the check box for “Allow Nuget to download the missing packages during builds”.
There are other option available if you don’t have VS installed and you need to enable this option for Build server e.g. CCnet etc. Just set the environment variable
EnableNuGetPackageRestore to "true".
If you are working with .Net 2.0 or so you can readout this to get the setting enabled restoring packages during build requires explicit consent from the user.
And you’re done. Next time you don’t need to carry those library files with your source controls. And this keep your repository neat and clean.