If you’ve spent any time working with open source .NET projects like Castle or NHibernate you’ll know the pain of building them from source. At first it seems very easy, you just get the source code from the repository and run the build.bat file or whatever. Any good OS project should just compile into a convenient build directory from which you can grab the assemblies you want.
The pain starts when you have several OS frameworks you are using that have dependencies on each other. Castle and NHibernate are the classic example here. Castle has a dependency on NHibernate and NHibernate has a dependency on Castle. I used to have to go through a complex build-copy-rebuild dance to get the two trunks to work with each other. These days I use a whole suite of open source tools:
Spark View Engine
And there are probably others I’ve forgotten. Getting all these from trunk and building them is a major headache.
If you’ve ever played with a Linux distribution, the really cool thing you’ll notice about it compared with the Windows world, is that you can get any software you need by typing (on Ubuntu for example)
apt-get install myFavoriteSoftware
It downloads and installs it on your system along with any dependencies. It’s quite amazing that Windows doesn’t have this yet.
But now this awesomeness is available for open source .NET projects and is supplied by Hornget. Hornget is the work of several members of the Scottish ALT.NET group, most prominently Paul Cowan. All you have to do once it’s downloaded and built (instructions here) is type:
Horn will update your local nhibernate source and all its dependencies and then build them in the correct order, copying the dependent assemblies into the correct places for the next build. It uses a Boo based DSL to configure the packages and many of the most important .NET OS projects are represented. I imagine that anyone with a serious .NET OS project is going to want to be included. It’s on my todo list to create a package description for Suteki Shop :)
The list of supported packages is here.
I just had a couple of hiccups getting it working. The first was that I didn’t have Git installed. Git is distributed source control from Linus himself. You can get a windows version from here. You want the ‘Git-22.214.171.124-preview20091022.exe ’ or whatever is latest. I couldn’t use the default Git protocol from work because our firewall blocks the Git ports. There is a work around, but for the time being I’m just using horn from home.
The second irritation was Powershell. Rhino tools, which many other projects have a dependency on uses Psake, the powershell build tool. You have to tell powershell to allow script execution by typing:
I was totally confused when after doing this, it still wouldn’t run Psake. It turned out that it was because I’m working on 64 bit 2008 R2 and typed set-execution policy in the 64 bit powershell. The Psake script gets run under x86 powershell which has a separate configuration. After I set the execution policy in the x86 powershell prompt, it all worked. Thanks to Steve Mason for pointing that out on the Hornget group.