tags:

views:

159

answers:

2

Hi,

As part of my Ant integration test script, I run an MSBuild build (just executing the msbuild.exe), and it works fine in the positive cases. However, Ant doesn't recognize when the msbuild build fails. How can I make it work?

EDIT:

I can msbuild by executing the executable:

<target name="executeMsbuild">
        <exec command="C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe /t:build-for-tests ${csharp.dir}\msbuild.xml"/>
</target>
+1  A: 

Provide failonerror attribute to exec.

Also provide a property formsbuild.exe path.

Also pass command line arguments as args

<target name="executeMsbuild">
  <property name="msbuild-prog"
    location="C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe"
  />

  <exec
    executable="${msbuild-prog}"
    failonerror="true"
  >
    <arg value="/t:build-for-tests"/>
    <arg file="${csharp.dir}/msbuild.xml"/>
  </exec>

</target>
Alexander Pogrebnyak
A: 

Using failonerror=true will give you an instant "BUILD FAILED" in case of an error and will be sufficiant in most cases.

For a more sophisticated error handling use = the try task from the Antelope tasksuite (1), which will give you a try/catch/finally (2) as in java. Antelope has also a limit task (3), which is a taskcointainer where other tasks are put in and provided with a timeout. Limit may be combined with try or use alone

In case someone mentions AntContrib, it's another ant task suite, that has equivalent tasks as Antelope ,but it seems the development of AntContrib has stopped (4)

(1) Antelope Tasksuite (2) Manpage try task (3) Manpage limit task (4) Antelope <> AntContrib

Regards, Gilbert

Rebse