0

I have a small issue in a nant build file.

Brief : we have a 2 build files EX (web and DB) which are independent and called seqentially..

nant -buildfile:web.build

nant - buildfile:db.build

To save time we are building it in parallel by adding a bat file and inside bat file we call both web & db

< exec program="parallel.bat" >

parallel.bat :

start web.bat

start db.bat

web.bat :

nant -buildfile:web.build

db.bat

nant - buildfile:db.build

it works fine but the concern is if there is any failure in web.bat or db.bat ... the build continues calling the remaining targets present in the main build file, without exiting .

Is there any way to stop the build if there is any failure or can we achieve the parallelism of web and db without using batch files (is there any task in nant ). we use MSBuild to build the web

Thanks,

Vishal

user3632330
  • 58
  • 1
  • 5

1 Answers1

0

Add a Wait command in each batch file. This will allow NAnt to finish executing the respective batch file before moving on to the other commands.

UPDATE:

Make reference to this.

Your NANT code what you edited :

<target name="build" >
  <exec file="Parallel.bat" />
  <other stuff..>
  <call target="others"/>
</target>

My suggestions...

<target name="build" >

  <echo message="Starting Parallel.bat file" />
  <call target="Execute.Parallel.batch" />

  <echo message="This means the Parellel target was successful..Moving on..." />

  <other stuff..>
  <call target="others"/>
</target>

<target name="Execute.Parallel.batch" >
  <exec file="Parallel.bat" />
</target>

Your Nant file should execute a main target that controls all the other targets. Since NAnt itself execute each target sequentially, this means that if your batch file fails, it will cause nant to also fail therefore would not execute any other targets after the Parallel.bat target.

Community
  • 1
  • 1
Geddon
  • 1,266
  • 1
  • 11
  • 31
  • i already have the wait command. After the 2 batch files are executed if any of the batch files fails (msbuild). the build is still progressing further without stopping it. – user3632330 Jun 03 '14 at 08:12
  • I think the way to have the parallel.bat set up, it will still run sequentially. See updated answer for another post you can reference to get the right format for your parallel.bat file. – Geddon Jun 04 '14 at 13:49
  • Is this msbuild part of the web.bat file only? IF so, as you stated it shouldnt be dependent on the others, right? Running in Parallel, will allow you to execute all individual components at the same time, but if one fails it would not affect the other because its "Running in parallel". If one fails and you want everything to stop, then you need to run them sequentially. – Geddon Jun 04 '14 at 13:58
  • right my parallel.bat file is exactly the same... but i am calling the parallel.bat file in a build file, if this fails (checking the error level , how do i do this). the entire build file should exit ? – user3632330 Jun 04 '14 at 15:20
  • In that case, It prob. how your build file is set up. I would create a target just for the parallel.bat file. This way any failure to any of those bat file it will stop at that target and exit.. Do you have something like that set up? – Geddon Jun 04 '14 at 18:38
  • i haven't used as shown above, my default.build file is shown as below : – user3632330 Jun 05 '14 at 08:39