Something I struggled with some time ago was what appeared to be a conflict of rules. Consider the Joel Test, where rule #2 states:
Can you make a build in one step?
In order to accomplish this, most developers place copies of any library dependencies into their source control. With the advent of NuGet, this seems even easier: just push copies of your nuget generated packages folder into source control as well.
However, in today’s world of distributed version control systems (DVCS) like git and Mercurial it is strongly discouraged that you place binaries into the repository. This leads to an impasse. How do we allow a 1 step build, while keeping NuGet out of the repository.
I solved this problem for my team by writing a simple batch file and adding the command-line nuget.exe to the root of my solution folder.
I added ignore statements for my packages folder, but added the repositories.config file to the git repository. My .gitignore looks something like this:
I then built a simple batch script to assist in reloading the nuget packages for my solution. The batch file looks similar to the following:
1: nuget install Fritz.TomatoTasks.Webpackages.config -OutputDirectory packages 2: nuget install Fritz.TomatoTasks.Web.Testpackages.config -OutputDirectory packages 3: pause
To note: the INSTALL command asks nuget to grab the versions of packages specified in the packages.config files from the nuget repository and install them. The -OutputDirectory switch specifies that the files are to be written into the standard packages folder.
Each time I add a project to the solution, I copy and paste a line into this file. This prevents us from having to worry about the storage of binaries, and we can add a command to our continuous integration server’s script to call this file in order to rebuild the solution from source control.
Do you have a way to improve my process? Let me know in the comments below or on Twitter at: @csharpfritz