I've talked about that little pet library of mine every now and then, and think it is time to give others a chance to look at it.
The thing I'm talking about is a small Ant task library that should work with Ant 1.6.x and provides three tasks:
- <dotnetexec> - a cousin of <exec> and in fact it will do the same as <exec> when you use Microsoft's CLR. On Linux though, it will default to use Mono and you don't have to say so explicitly, just specify the assembly as executable. There also is an attribute to give you more control in case you want to run Rotor or Mono on Windows for example.
- <nant> - run NAnt from within Ant. Usage ranges from running an existing build file to specifying the NAnt build file in-line.
<nant> <build> <nunit2> <formatter type="Plain"/> <test assemblyname="MyProject.Tests.dll" appconfig="MyProject.Tests.dll.config"/> </nunit2> </build> </nant>
runs NAnt's NUnit task from within Ant. This is supposed to work transparently using Mono or Microsoft's CLR. - <msbuild> - similar to <nant> but for MSBuild. This is probably not going to work at all, but I wanted to include it anyway. In particular nested build files won't work since Ant insists on lower-casing everything before it passes it to the task.
All of these tasks have only been tested using Mono on Linux and MacOS X so far. The docs are online - also as an archive. An Ant 1.6.x compatible antlib is here..
The CVS HEAD version contains a WiX task as well, but I'm not sure about its current shape, so I've left it out for now.
Any feedback is appreciated.
path: /en/Apache/Ant/dotnet | #
The small Ant library I have talked about before has undergone some changes and it has been polished up a little.
The <dotnetexec> task now works well on Linux if I place the assemblies somewhere arbitrary into my PATH, <nant> works like a charm, in particular this here
<ant:project xmlns:ant="antlib:org.apache.tools.ant" xmlns="antlib:org.apache.tools.ant.taskdefs.optional.dotnet"> <nant> <build> <echo message="This is NAnt"/> </build> </nant> </ant:project>
results in
Buildfile: /tmp/nant.xml [nant] NAnt version 0.8.4 Copyright (C) 2001-2003 Gerry Shaw [nant] http://nant.sourceforge.net [nant] Buildfile: file://tmp/build2001946168.xml [nant] [echo] This is NAnt [nant] BUILD SUCCEEDED [nant] Total time: 0.1 seconds. BUILD SUCCESSFUL
which means, I've just run NAnt's <echo> task from within an Ant build file using Mono 0.28 on Linux. All that is required to do so is NAnt.exe in my PATH and dotnet.jar in my CLASSPATH (and a freshly bootstrapped CVS version of Ant).
The docs are online as well.
path: /en/Apache/Ant/dotnet | #
I've started to write some Ant tasks to improve Ant's .NET support even further (it already compiles C# or J# and does a couple of more development centric things). I started with a task that extends <exec> in a way that it should transparently invoke Mono if I point its executable attribute to my assembly on Linux - it still has some problems that are probably more due to Mono and my inexperience with it than with the task.
As a side effect and to test it, I've written <nant> and <msbuild> tasks that can invoke either build tool. So far only build file, targets and properties are supported, but I plan to support nested build file snippets in the future.
Right now you can use something like
<nant buildfile="src/nant.build"> <target name="echo"/> <property name="foo" value="bar"/> </nant>but in the future one should be able to use
<nant> <build> <nunit2> <test assemblyname="MyProject.Tests.dll"/> </nunit2> </build> </nant>to invoke NAnt's <nunit2> task. Ant would create a temporary build file with the snippet and run NAnt on it.
The <msbuild> task is complete speculation as I don't have access to MSBuild at all (I've written the task only from reading the command line reference) and the <nant> task fails on Linux unless I install NAnt and all related assemblies (they are in my PATH) in /usr/local/bin - there must be something wrong here, setting MONO_PATH doesn't help either.
The code can be found in the proposal/sandbox/dotnet directory in Ant's CVS module. The top in WebCVS is here.
path: /en/Apache/Ant/dotnet | #