Dependency Management in .Net: install2

On September 27, 2011, in Uncategorized, by derekgreer

Inspired by Rob Reynoldsawesome post on extending NuGet’s command line, I decided to create my own extension for facilitating application-level, build-time retrieval of external dependencies along with all transitive dependencies. I struggled a bit with what to call the command since what it does is really what I believe the regular install command should be doing (i.e. installing transitive dependencies), so I decided to just call it install2. Here’s how to use it:

Step 1: Install the NuGet Extension package by running the following command:

$> NuGet.exe Install /ExcludeVersion /OutputDir %LocalAppData%\NuGet\Commands AddConsoleExtension

Step 2: Install the extension by running the following command:

$> NuGet.exe addExtension nuget.install2.extension

Step 3: Create a plain-text packages file (e.g. dependencies.config) listing out all the dependencies you need. For example:

NHibernate 3.2.0.4000
Moq

Step 4: Execute Nuget with the install2 extension command:

$> NuGet.exe install2 dependencies.config

If all goes well, you should see the following output:

Attempting to resolve dependency 'Iesi.Collections (3.2.0.4000)'.
Successfully installed 'Iesi.Collections 3.2.0.4000'.
Successfully installed 'NHibernate 3.2.0.4000'.
Successfully installed 'Moq 4.0.10827'.

Enjoy!