Should .nuget folder be added to version control?

Solution 1:

This post is old, you should not be using solution level NuGet package restore anymore. As of version 2.7+ there is an option in the NuGet setup to automatically restore packages on build. So the .nuget folder can be deleted and the option removed from your projects.

http://docs.nuget.org/docs/reference/package-restore

UPDATE: With the release of NuGet 4.x and .NET Standard 2.0, when you use the new csproj format you can now use package references, ironically reintroducing the dependency on msbuild to restore packages, but now packages are a first class citizen of msbuild. The link above also makes mention of the PackageReference, but the following announcement details it better:

https://blog.nuget.org/20170316/NuGet-now-fully-integrated-into-MSBuild.html

And the NuGet 4.x RTM announcement, which ironically isn't as useful:

https://blog.nuget.org/20170308/Announcing-NuGet-4.0-RTM.html

UPDATE 2: Apparently with VS2017 you can even use package references with classic csproj projects, but they aren't backwards compatible anymore, and there have been some problems with restoring package sub-dependencies. I'm sure that will all be resolved.

Solution 2:

@Richard Szalay's answer is right - you don't need to commit nuget.exe. If for some reasons Visual Studio does not automatically download the nuget.exe, make sure you have the following set to true in the nuget.targets file:

<!-- Download NuGet.exe if it does not already exist --> 
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">true</DownloadNuGetExe>

Close the VS solution, reopen it and build it. Visual Studio should download nuget.exe automatically now.

Solution 3:

According to this thread, the .nuget folder should be version controlled.