Saturday, March 04, 2006

Using Ant's dotnet lib

The Ant framework now has support for using dotnet tools. Of particular interest, is support for msbuild, which is actually a similiar tool as Ant with Microsoft flavor to it. This can provide a lot variations for automated builds. However, there are few tricks in getting Ant's framework support for dotnet going. If you are having problems using or installing Ant's new support for dotnet, read on...

Ant's framework doesn't inherently support the ant-dotnet.jar until version 1.7.*. So, until then, you will need to patch ant to include. If you are an experienced java developer, this will be an old hat to you. If you are not that familiar with developing or compiling java components, follow the following steps (Note this assumes that have the java compiler installed and in your path):

1. grab this (http://cvs.apache.org/~bodewig/dotnet/ant-dotnet.jar) and place in the same dir as your other ant jars (assuming that you have set an environment variable ANT_HOME, when you installed ant, this would be %ANT_HOME%\lib) Note: My system kept on downloading the file as a '.zip'. It is actually a .jar. Rename as such if necessary.

2. . Also grab (this) XMLFragment.java java file. This is file that you will need to compile and add it into the main ant.jar You can do this by the following:

3. setup a src directory, to the effect of

<basedir>\apache\tools\ant\util

Basedir can be any dir, but the directory structure beneath must be the same.

4. copy the xmlfragment.java file into \org\apache\ant\dotnet\tools\ant\util

5. at a command prompt:

cd <basedir>basedir>\org\apache\ant\dotnet\tools\ant\util

6. javac -classpath %ANT_HOME%\lib\ant.jar XMLFragment.java

7. cd <basedir>

8. jar uvf ant.jar org\apache\tools\ant\XMLFragment.class

9. copy /y ant.jar c:\Java\apache-ant-1.6.5\lib

That's all there is to it.