The HornGet Project: Bringing "apt-get install" to .NET Projects

For years I used nothing but Windows.  When I started getting into robotics (for fun - let me know if you'd like me to do it professionally ;), I had to dive into the Linux world.  After only a couple of weeks with Ubuntu, I was stunned at how far behind our Microsoft-following community is in some respects.  Take Linux's "apt-get install" command, for example.  Running this simple command, followed by an application name, finds the referenced application on the "Information Super Highway," downloads the binaries and installs it locally.  No biggie, right?  Well it also looks to see what dependencies the application has, downloads the latest of all of them, and installs them as well before installing the target application.  It does all of that with just one command line (and sometimes even successfully! ;).

There are two scenarios that come to mind where something like "apt-get install" is tremendously useful when developing a project.  The first, and most akin to the intent of "apt-get install" is when you're managing an open source project (e.g., S#arp Architecture) and want to provide an easy way for developers to get the latest of the project while concurrently grabbing the latest of its dependencies (e.g., Rhino tools, NHibernate, Fluent NHibernate, MVCConrib) in the process.  The second scenario is if you have a project which has a large number of dependencies and dread checking for updates to the project dependencies.  Which dependencies do you download?  Where do you find the source?  Which order should you build them in?  How do you know, except through a lot of tedious snooping, which secondary dependencies are also involved in rebuilding the project dependencies?

The HornGet project is attempting (and succeeding I might add, even in its pre-beta form) to greatly ease the burden of updating dependencies of complex projects.  With Horn installed and configured, it only takes a single command line to get the latest of your favorite OSS project or to rebuild your project's dependencies.  Similarly to "apt-get install," you simply tell Horn what you'd like to have built and it does the rest.  There's a full listing of all of Horn's supported packages found at http://code.google.com/p/hornget/wiki/SupportedPackages.  As you can see, Horn supports a wide variety of projects such as NHibernate, Castle, LinFu, Ninject, AutoMapper, Subsonice, MVCContib, S#arp Architecture, and many others.  Something quite unique about Horn is that it even checks for indirect, bi-directional library dependencies.  For instance, NHibernate depends on a Castle project while one of the Castle projects depends on NHibernate.  Horn is smart enough (through config files) to know which projects to build in which order to resolve such scenarios.

The best way to experience and appreciate Horn is to try it out.  The following steps demonstrate using Horn to automatically download and build the latest of NHibernate with updated dependencies:

  1. Install TortoiseSVN (if you haven't already) to download Horn and to be used during the build process.
  2. Install msysgit as some of the dependencies will be downloaded from from Git distributed source repositories.
  3. Make sure that "C:\Program Files\Git\bin" and "C:\Program Files\Git\cmd" are included in your Environment Variable's PATH (and add them if not)
  4. Install Windows PowerShell (used during the dependency build process - it's included in Win 2008 automatically)
  5. Open a PowerShell command prompt and run "set-ExecutionPolicy RemoteSigned" to allow Horn to invoke PowerShell commands used during the dependency build process.
  6. Use SVN command line or TortoiseSVN to get latest of http://hornget.googlecode.com/svn/trunk/ to a folder we'll call HornRoot
  7. (Here's the only kludgey part, which I'm sure will be cleverly resolved very soon...)  Open /HornRoot/src/Horn.Console/Program.cs in Notepad, or whatever, and modify, under GetRootFolderPath(), the line "var ret = new DirectoryInfo(rootFolder);" to be "var ret = new DirectoryInfo(@"C:\...\HornRoot\" + PackageTree.RootPackageTreeName);" and save/close the file - replacing C:\...HornRoot with a real file path.  NOTE:  Make sure there are NO spaces in the file path that you provide.  PowerShell abhors spaces in file paths.
  8. Open a command prompt, cd to the /HornRoot/src folder and run "hornbuild.bat"...you be triumphantly rewarded with a BUILD SUCCEEDED message...but that's just the Horn project.
  9. In the same command prompt, cd to /HornRoot/src/build/net-3.5/debug and run "horn"
    • You should see the Horn usage guidelines...that's a good sign.
    • At this point, Horn is now installed, ready and configured to build any of the supported packages.
  10. As an example, run "horn -install:nhibernate" (and be patient as it'll take some to run...30 minutes to an hour or more for a project with many dependencies is possible probable)
    • After executing this one liner, horn will spit out a whole bunch of "working......" statements as it figures out what NHibernate's dependencies are, downloads the source of the dependencies, builds them, and then downloads and builds NHibernate with all of the updated dependencies.
    • Keep waiting...Horn is doing a LOT of tedious work for you right now.  Don't be surprised if you see very long strings of "working......" statements at a time, throughout the build process; this is expected as it downloads each project dependency and builds them, accordingly.  Go get another cup of coffee or something.
    • Assuming the OSS world is in a Zen-like state with each other you'll get a number of BUILD SUCCEEDED messages for each project dependency and then eventually get a BUILD SUCCEEDED message for the target project itself.
    • Horn outputs its results (the updated DLLs) into /HornRoot/.horn/result.  Don't worry if there are more DLLs that you expected; just grab the updated ones that are applicable to your project and you're good to go.

If you've ever tried to update a bunch of project dependencies, you'll appreciate the enormous time savings in using Horn to pull together the dependencies for you.  Doing this manually usually takes me at least a few hours to get latest of all dependencies, build them, and build them with S#arp Architecture.  With Horn, it takes a one liner and a coffee break.

How does it do this magic you ask?  Good question!  Each project that Horn supports has a Boo configuration file; e.g., the S#arp Architecture Horn description is at http://hornget.googlecode.com/svn/trunk/package_tree/frameworks/sharp.architecture/sharp.architecture.boo.  The file speaks for itself in describing what dependencies are necessary for the project and where to find the source of S#arp Architecture itself.  So when you run "horn -install:sharp.architecture" (which takes a very long while mind you) Horn references the respective project description file and off it goes.  It's really quite a remarkable feat that Horn has pulled off.

Horn is still maturing - it's not even beta yet - but it's quite a time saver already.  So if you have ideas, would like to get involved, or have a project that you'd like to have added to the roster, be sure to let the Horn team know.

For more Horn:

Enjoy!

Billy McCafferty


Posted 10-29-2009 8:34 PM by Billy McCafferty

[Advertisement]

Comments

David Kemp wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 5:04 AM

This is really good work - almost like ruby-gems. TBH, I've thought of writing something like this myself for a while, annoyed at the lack of cohesion in OSS in the .Net world, but often even getting one of these projects to just compile takes a few hours.

Thank you.

Bart Reyserhove wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 5:09 AM

Why do you need step 7? If it is to change the Horn output path you could also use the  -output option in the command line: code.google.com/.../UserFAQ

uberVU - social comments wrote Social comments and analytics for this post
on 10-30-2009 6:07 AM

This post was mentioned on Twitter by devlicious: New Blog Post The HornGet Project: Bringing "apt-get install" to .NET Projects: For years I used n.. http://bit.ly/2wbaKQ

Paul Cowan wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 6:17 AM

@David

It is not only a lack of cohesion in the .NET OSS world, it is the complete ambivalence by the big players to even caring about the pieces fitting together.  I have championed horn to Nhibernate, Castle and Rhino and at best I have received a mild response.  This is well down the agenda for the dev.s on these projects.  I simply cannot get interest from them on this subject.  If not horn then we need something to ease the burden of updating and getting builds.

@Bart,

Step 7 is necessary because the psake file that builds the new Rhino projects calls msbuild and these files do not take into account spaces in the path. THe code needs to change so the user can specify where the horn root directory of descriptors is.

Aleks wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 6:39 AM

Just a quick note: "apt-get install" will install a pre-build binary, not compile from source.

James Chaldecott wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 9:10 AM

Looks cool.

We needed something like this, but for binaries at my work. We have a multi-stage build, and we want to get binaries from earlier stages in the build from our build server. Some of those binaries are locally built OSS projects, some is our own code. We don't want devs to constantly have to rebuild *everything* locally when some basic dependency changes, but we do want them to be able to use the most recent stuff as soon as it is available.

The only thing we found is Apache Ivy. It's Java, but that doesn't really matter unless you need to make changes or fix bugs. The only real complaint is that the command-line interface doesn't have access to all the cool stuff you can do when you use it through Ant.

Billy McCafferty wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 9:14 AM

Thanks for clarifying Aleks; I'll correct, accordingly.

jdn wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 10:37 AM

Dumb question, but does it know to download the correct dependencies only for itself?

That is, I might have 4 projects that each compile against different versions of, say, StructureMap.  I wouldn't want project 1's dependency on SM v.Whatever to get over-written by project 2 downloading and compiling SM v.SomethingElse.

Sean wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 12:38 PM

Hmm...my Horn build is failing...

BUILD FAILED - 0 non-fatal error(s), 4 warning(s)

I assume it's something I'm doing, any idea where these logs are?  can't seem to fin'e,.

Billy McCafferty wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 12:50 PM

@jdn, it downloads the version based on the project description file, written in .boo.  So you could have multiple projects, each with different versions.

@Sean, please bring up the issue you are running into on the Horn forum at groups.google.co.uk/.../horn-development for comprehensive support.  Thanks!

NG wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 1:45 PM

I've moved to doing some Java work from the .NET world and find Maven awesome. As well as managing dependencies, the convention over configuration build phases are awesome.

Sean wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 4:58 PM

Actually, I got it working. I needed "C:\Program Files\Git\cmd" in my path rather than "C:\Program Files\Git\bin".

Billy McCafferty wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 10-30-2009 5:02 PM

My fault Sean!  I'll correct, accordingly!

Bob wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 11-03-2009 9:50 AM

Is this getting the latest STABLE build of everything, or getting the latest from the trunk?  I shouldn't need to ask, IMO, but the number of tutorials, etc that I've read that advocate grabbing from the trunk are unnerving.

Billy McCafferty wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 11-03-2009 4:46 PM

Bob, you are correct in assuming that it grabs from the trunk.  As you've implied, that must be taken carefully into consideration if you will be using Horn.

Steve wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 11-10-2009 9:19 AM

Any chance we see an installer out of this - install it, it updates automatically and makes it easy to command line / or GUI find and install packages ?

Yonah Wahrhaftig wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 11-10-2009 9:24 AM

I was having trouble with PowerShell execution policy on an x64 system until I found this thread on the group discussion board groups.google.com/.../fdfd1eba7f6737b8.

You may want to note that the execution policy must be set on the x86 version of powershell.

Thanks for a great article.

Hadi Hariri's Blog wrote Getting your OSS binaries with Horn
on 11-23-2009 3:54 AM

Getting your OSS binaries with Horn

Hadi Hariri's Blog wrote Getting your OSS binaries with Horn
on 11-23-2009 3:55 AM

Getting your OSS binaries with Horn

Hadi Hariri wrote Getting your OSS binaries with Horn
on 11-23-2009 3:57 AM

Recently Billy McCafferty wrote a post on Horn, a package manager that Paul Cowan and Dave the Ninja

Thick yoha mat wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 03-23-2010 7:40 AM

Really good project

pine bunk beds wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 07-29-2010 10:22 AM

Interesting project

best fake tan wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 09-01-2010 6:29 AM

I'm also getting:

BUILD FAILED - 0 non-fatal error(s), 4 warning(s)

Any ideas?

Thanks

Mother of Pearl Jewelry wrote re: The HornGet Project: Bringing "apt-get install" to .NET Projects
on 01-18-2011 9:41 AM

Just a quick note: "apt-get install" will install a pre-build binary, not compile from source.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)