.NET Dependency Management

The problem

One of the features that I miss when I work in .net is a tool to retrieve my dependencies (i.e. assemblies, tools) from a centralized server to avoid copying them again and again from project to project.

In the java world Maven does that (and much more) for you, and in the Rails world a utility called Gems (a gem is a ruby library) exists that will download and install the dependencies of your project for you.

To illustrate the point, let’s look at the .NET Media Library project. The project file structure looks something like this:

+—Media Library

+—Main: main source, all the projects are in here.

+—Test: Testing source, all the testing projects are in here.

+—Lib: Dependencies for the projects.

+—Tools: Tools to be used to build, test, deploy, etc.

I have to potential candidates to store external resources (actually I’m using SVN externals, but is giving me lots of grief), lib and tools.

Under lib I have the libraries like:

And under tools I have

Every library and every tool has a particular version, even some of them have dependencies on their own that I have to compile, store and copy every single time I start a project or I want to upgrade.

What to do? What to do indeed….

A new project is born

What to do? Create my own, of course.

Disclaimer: I don’t want to reinvent the wheel, so, if you know of a similar project, please let me know ASAP!

My goal is to build a tool that will use a configuration file in which I can declare my dependencies and will download them from a known host.

Similar to Gems I’d like to use a DSL (Domain Specific Language) to be declarative and have a clear syntax to describe, versions, sources, targets, aliases, etc.

However, I’d like to take advantage of another language that I can build on top, to have lots of features out of the box that otherwise I need to implement on my own.

Don’t be scared, BOO is here!

What better candidate than Boo? Quoting the site:

Boo Boo is a new object oriented statically typed programming language for the Common Language Infrastructure with a python inspired syntax and a special focus on language and compiler extensibility.

After using Binsor in a few projects I was convinced that Boo is an excellent choice to build the tool. So my first step was to buy the book DSLs in Boo: Domain-Specific Languages in .NET, and start reading.

First Draft DSL Syntax

Let’s imagine that we want to declare dependencies for the .NET Media Library, here is my idea so far:

lib_folder lib
source http://MavenThought.com/nass

# Testing libraries
lib MavenThought.Commons, 0.2
lib MavenThought.Testing, 0.2
lib nunit, 2.5
lib SharpTestEx, 1.0
lib SpecFlow, 1.2

# Castle Stack
lib Castle.Core, 1.1
lib Castle.Windsor, 2.0

# ORM
lib NHibernate, 2.1
lib SQLite, 2.1

# Web framework
lib OpenRasta, 2.0.3
lib JSon.NET, 3.5

The lib keyword declares the dependency and the version and we can see at the top the configuration for the destination folder and the source to get the dependencies. Because we are using Boo we can use the comments, etc…

Any feedback?

Tags: ,

This entry was posted on Saturday, May 8th, 2010 at 5:29 pm and is filed under Build Tools, Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

5 Responses to “.NET Dependency Management”

Sean May 20th, 2010 at 4:14 pm

Sounds good. How do you get the dependencies when you first download the project? Msbuild task?

admin May 20th, 2010 at 11:52 pm

You can invoke the command line to update the program, or use an MSBuild task that would invoke the actual program.

Mitchell Lee June 13th, 2010 at 8:18 am

Hey Amir,

Not 100% the same as what you are doing with this, but there is another project with a similar goal of having dependencies satisfied for you.

http://code.google.com/p/hornget/

I like you, was looking for something like that or to build something like that.

admin October 7th, 2010 at 2:34 am

Just after I wrote the post, OpenWrap was announced :-) .
If u want to use gems you could use the Nu project or Noodle + Bundlers.
NuPack is another OSS option that recently came to my attention.

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes