Should .nuget folder be added to version control?

Feb 5, 2012 at 10:22 AM

(This is a copy of a question on StackOverflow)

With newer versions of NuGet it is possible to configure a project to automatically restore NuGet packages so that the packages folder doesn't need to be included in the source code repository. Good.

However, this command adds a new .nuget folder and there is a binary there, NuGet.exe. This can also be re-created automatically by Visual Studio and so it doesn't feel correct to add that to version control. However, without this folder Visual Studio won't even load the solution properly.

How do you people deal with this? Add .nuget to source control? Run some command line script before opening the solution?

Feb 5, 2012 at 1:04 PM

Yes, you are supposed to check in the .nuget folder.

Feb 16, 2012 at 5:43 PM

We have a lot solution files and don't really want to pollute our repository with all this info.  Is there any way of disabling this feature from nuget?  We are considering rolling back to an older version of nuget to get around this pain.

Developer
Feb 16, 2012 at 6:07 PM

@mikedivestco, as of 1.6, the .nuget folder is not added to your VS solution unless you Enable Package Restore.

However as part of 1.7, we are working on adding a solution level packages.config that would be a combination of what was repository.config (under the packages directory) and a store of solution level packages (packages that aren't referenced by individual projects like msbuild files). We are looking at reducing the footprint of the binary located under the .nuget directory.

Feb 16, 2012 at 7:10 PM

Ok thanks for the info.

For us, it would have been better if the "Enable Package Restore" option could be toggled at a .csproj level instead of going through and automatically adding itself to every .csproj in the entire solution.

Feb 16, 2012 at 7:36 PM

In 1.7, we have made a change so that calling "Enable Package Restore" will only modify the .csproj of the projects that have at least one nuget package installed. Does that work for you?

Feb 16, 2012 at 7:40 PM

It would be better, but best would be to only enable it on a specific project and not go changing other csproj files.  As we have some projects using that feature and some not.