NUnit Hangs Up When Run Through Nant Using .Net 4.0

Ran into this one yesterday starting with Cruise Control not finishing. At first I just thought Cruise Control just wasn’t that into it, but turns out something was hanging up and that something was N-N-N-UNIT. Well to be more specific it was NUnit while being run through Nant although in the end it wasn’t Nant’s fault. Turns out it has to do the latest stable release of NUnit… 2.5.8.something.whatever.

The fix? Grab 2.5.9.yayayaya from the download page and use the nunit-console from that instead. I guess the whole issue had to do with the latest .Net 4.0 and the latest stable version of NUint. I guess they don’t like each other. They go together like water and something that doesn’t go well with water.

Failure scanning CollectionGen.dll for extensions.

Quick hit, you might get this if you try loading the bin directory of the nantcontrib project AND YOU DIDN’T FOLLOW THIS POST.

Solution, FOLLOW THIS POST or you can simply remove the CollectionGen.dll from the bin directory. However if you do that, you aren’t helping my bounce rate and that makes you a Communist… unless you are a Communist then it makes you a Capitalist.

How to Install/Using NantContrib BECAUSE THE DOCUMENTATION SUCKS

I understand I’m not what you call the sharpest bulb in the bunch, but readmes shouldn’t be painful. They should be helpful. They should be kind and gentle, and remind you that the world is great and wonderful. Not put you on the verge of a three figure body count. In a way, this is why I’ve shied away from a lot of open source stuff since the readme files read like instructions for putting together something from IKEA. And not the horrible broken English ones, more like the ones with all those funny squiggly lines. (I think it’s call “Chinese”) Why is it always so painful to figure something out WHEN YOU HAVE INSTRUCTIONS? Best hint on writing instructions, always assume the person you’re writing to is an idiot. You can infer from that whatever you want.

Anyhow, NantContrib, the library of things that adds on to Nant (With brilliant ideas like being able to add an else to an if WOW), is a victim of nothumanenoughtowriteadecentreadmefileinawaythatnormalhumansunderstanditis (Otherwise known as Thoreau Syndrome) so I thought I would save you some together time between your head and your monitor.

Now you could go download it from wherever it is, or you can just grab this which is nantcontrib post “fixing” it. Basically if you get my version, all you have to do is drop it somewhere, anywhere, and extract. I put it in the same directory that Nant is, so they sort of sit side by side but separate. A happy little couple, at least for the first few years until Nant has a mid life crisis and decides it’s time to get a Corvette and start rolling for college girls at which point nantcontrib starts eying the Fedex guy. Right now, its idealistic bliss.

Once you’ve done that, all you have to do is drop this bit into your nant script, probably above your properties, but it possibly can go other places. I haven’t really looked into that.

<loadtasks>
  <fileset>
    <include name="c:\nantcontrib\bin\lib\" />
  </fileset>
</loadtasks>

And now you are ready to go.

Now you might be curious about what I did to the directory structure of the nantcontrib stuff. It’s actually pretty simple. I just took the bin folder and split it up. (Something I kind of pieced together from random pages) I took what I understand to be the important stuff (All the dlls except CollectionGen.dll and SlingShot.core.dll.. wait I’m sorry SLiNgshoT.core.dll cause f—ed up casing means its that much better. ITS HARDCORE MAN! TO THE XXXXXXXTREEEEMEEEE!) and put it into a new folder “lib” that still resides in the bin folder. The rest of the stuff went into a new folder “tasks”. Then I had the loadtask command include everything in bin\lib. Boom, everything works as it should.

Using Subversion With Nant: Automated Checkouts From Config File

This is the first part of a I HAVE NO CLUE HOW MANY part thing involving Nant and how to use it to make your life easier. Of course you might wonder why I’m using Nant over say MSBuild, (Though I’m sure you were actually wondering if you really can get ripped in two weeks) and I have no real reason other than at some point this will tie into Cruise Control for easy deployments. Fact is, the debate between nant and msbuild is an ongoing war between the hopeless broken records known as Microsoft haters and the mindless Microbots. Personal, I don’t really care since they are both fine. I may some day switch to MSBuild but for the scope of this article that MIGHT BE A BIT STUPID AND HYPOCRITICAL.

Also you might wonder about why I’m using subversion instead of say Team Foundation Server. (And no you can’t get ripped in two weeks) Probably has to do with the 10k I don’t have to shell out for something that is about two generations behind subversion… and that’s saying something since subversion is about two generations behind source control in general. But my subversion hosting is 3.95 a month. So it really comes down to what is the only thing that matters when developing: Money.

Say you have someone new coming in and you want to be able to have said person be able to get a project from a subversion repository without really thinking. (You can’t assume new people think.) This is mostly helpful because chances are you’re place of employment is a revolving door just like every other place. So the thought of automation comes to mind. What if I told you getting things from a subversion repository is as easy as a config file? “Balderdash!”, you say. “The f— is balderdash?”, I reply. And at somepoint we talking an common language and I show you this:

<project name="ToolInstall" default="download">
  <property name="toolProject" value="ToolsProject" />
  <property name="svnLocation" value="c:\program files\subversion\bin\svn.exe" />

  <target name="clean" description="cleans build directory">
    <delete dir="${toolProject}" verbose="false" failonerror="false"/>
  </target>

  <target name="download" description="gets projects from repository" depends="clean">
   <exec program="${svnLocation}" commandline="checkout http://some.repository.com/trunk/src/ToolProject ToolProject --username tool --password somepassword"/>
  </target>
</project>

What’s all of this? Well I am here to break it down. Oh Oh Whoooaaa.

<project name="ToolInstall" default="download">

First element of the file has to be project. The name isn’t all that important to this example, however Default means whith taget it will run first if you don’t tell it.

  <property name="toolProject" value="ToolsProject" />
  <property name="svnLocation" value="c:\program files\subversion\bin\svn.exe" />

Think of a Property as a variable. They just allow you to take out as many repeated strings as possible. You’ll see that the svnLocation Property points to where subversion was installed. This will vary per computer if you didn’t specify the name of the install directory.

  <target name="clean" description="cleans build directory">
    <delete dir="${toolProject}" verbose="false" failonerror="false"/>
  </target>

A target is basically a task you need to have done. It could be anything from deleting junk, running tests, or getting you a date. (HAHA ITS FUNAY CAUSE THATS IMPOSSIBLE) For this one, it is simply removing a folder that may exist. You can use this same idea to remove bin and obj folders if you use nant to build your project or simply clean it… But I’ll get to building in another post.

  <target name="download" description="gets projects from repository" depends="clean">
   <exec program="${svnLocation}" commandline="checkout http://some.repository.com/trunk/src/ToolProject ToolProject --username tool --password somepassword"/>
  </target>

And there’s the best part of the post, using nant to grab something from a subversion repository. As you can see, I’ve used the svnLocation property to make it easier to set what Program to use. I think this target is pretty much self explanitory for anyone with an IQ higher that that of a potato.

Next step is just to create a batch file to call nant and run this config file. Let’s assume you called it Nant.install. I know, it’s so descriptive, it’s genius. Shut up, I get the sarcasm.

Here’s the batch file:

@..\nant\nant.exe -buildfile:Nant.install

Mind you @..\nant\nant.exe will change depending where your copy of nant.exe is, but I figured I leave that in the way it is just to show that it doesn’t have to reside in the same place.

And there you have it, subversion and nant together like two children frolicking in the forests of Bavaria. (Assuming they have forests there and me mentioning kids isn’t creepy) In my next post I’ll probably go more into nant itself, this was just kind of on a whim. And I don’t know why I am appologizing for this. Stop f—ing judging me.