NAntScript, now with added functions
When we’re doing C# work, we’re fairly big fans of NAnt, as it’s a very good build system for .Net. However, it’s got a few small flaws, the main one of which is that you often end up repeating yourself a fair few times, and applying any sort of DRY thinking in it is quite hard.
Enter NAntScript. Originally from some folks elsewhere, but languishing and somewhat abandoned and in need of some work. The core idea being that you can write new tasks for NAnt using existing tasks (it is in fact also possible to write new NAnt tasks using C# or various other languages, but that’s a pretty messy way to work)
This enables you to write common sets of tasks e.g. a copy with a filter for templating, as a new task which can then be repatedly reused.
However, NAntScript had a few little flaws. It didn’t work on modern NAnt instances (luckily a small fix), there wasn’t any online documentation for it (also now fixed), and you couldn’t write functions with it, and that last one is the really fun new one I’ve added.
In the same way as the earlier taskdef let you create a custom task, funcdef lets you make a custom function. Functions are a bit different, in that they’ve got properly typed inputs and outputs, and that you’ve got to figure out a way how to get a value out without breaking NAnt syntax too badly, but that’s solvable in a similar way to how variables work in func/taskdef’s. Variables are defined as being called some “foo” and then they are inserted any time you enter the magic text “__foo__”, and the return works in a similar way, defining a magic return variable called “__$return__” which must be set at some point during the internals of a function. Here’s an example of that. Source as usual is on github, and I’ve even added some precompiled binaries for download.