What is the right way to add .NET project with NuGet dependencies to a git repo?

I have a project(s) that I'm writing NUnit tests for (for example). I want to commit the code to git, but I also feel it's bad practice to commit the NuGet packages (NUnit and NUnit.Runner) to the repo. However, I don't want to also turn on Package restore either since I believe it's a user setting and not a project setting (IIRC).

What is the right way to add .NET project with NuGet dependencies to a git repo? I assume it would be something that would happily grab the Packages but one that requires developer intervention. Perhaps just expect other developers to know to add those missing packages back into the project? (It also seems like we'd end up resolving .csproj conflicts all the time too).


If unable or unwilling to enable package restore, a developer can easily add all packages by command line, as explained in this question:

You can use nuget.exe to restore your packages. Run the following command for each project.

nuget install packages.config

You can also run this in a pre-build command, as explained here:

$(SolutionDir)Tools\nuget install $(ProjectDir)packages.config

But really, package restore is easier, it merely requires a few clicks.

You should add your solution's packages.config file only to your git repo. From it every developper will be able to install needed package automatically.

For example, under Visual Studio 2012 at least, you can check the 'Allow NuGet to download missing packages during build' checkbox in the 'Package Manager Settings' window accessible under the 'Tools' > 'Library Package Manager' menu. With this option and the packages.config file you have nothing else to do...

Need Your Help

How to merge commit in Gerrit Code Review

git merge commit gerrit

I'm newbie to gerrit: http://code.google.com/p/gerrit/

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.