Dependency Management in .Net: install2
Inspired by Rob Reynolds’ awesome 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 22.214.171.12400 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 (126.96.36.19900)'. Successfully installed 'Iesi.Collections 188.8.131.5200'. Successfully installed 'NHibernate 184.108.40.20600'. Successfully installed 'Moq 4.0.10827'.