With NuGet 2.0, you don’t have to commit the packages to the source control along with the source files. This makes the source code management much faster and easier without having to check-in and lock all the assemblies and related files that are part of the NuGet package.
NuGet supports restoring of packages as part of the build process. To enable this feature, you need to configure the NuGet settings on each build server that is used to build the projects to restore packages during build process. For build servers that have visual studio installed, you can use the NuGet package manager settings to configure this property like given below.
If your build server does not have visual studio installed, then you need to mention this as an environment variable as given below.
PS C:\> $env:EnableNuGetPackageRestore = $true
The next step is to add the details of the package sources to the solution that need to be build. To add the restore package options while building the project, right click the solution in the solution explorer window in visual studio and choose the option “Enable NuGet package restore” option.
This will add a new solution folder named .NuGet to the solution, with 3 files (NuGet.exe, NuGet.targets and NuGet.config).
In the NuGet.targets file you can see the details for the package sources and details on whether the download the NuGet executable is needed etc. In the configuration file, the setting that instructs version control systems like TFS not to add the NuGet packages folder to the pending check-ins list is configured.
?xml version="1.0" encoding="utf-8"?>
<add key="disableSourceControlIntegration" value="true" />
The package sources are normally configured in a Config file at location %APPDATA%\NuGet\NuGet.Config in the build server. This file is created when you configure the package sources from the visual studio package manager settings dialog. If the source is not configured from visual studio, you need to add the sources to the NuGet.targets file as given below.
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />