calling batch files inside nant
Asked Answered
H

3

6

How can I call a batch file inside a nant script??? (Maybe having a target that calls the batch file).

Hixon answered 10/3, 2009 at 18:7 Comment(0)
D
8

That's pretty easy, actually - i'll try to illustrate:

 <target name="run-command">
   <exec program="ConsoleTest.exe" basedir="${test.dir}">
     <arg value="-cp" />
   </exec>
 </target>

The basedir is optional, it specifies where to run the program from. But if your program is on the path (like ping), you probably don't have to worry about it.

Have a look at the official documentation as well :)

Delisadelisle answered 19/3, 2009 at 17:43 Comment(0)
E
2

Before dropping to a batch file have you considered the tasks in nantcontrib? I needed to smoosh some little javascript files together and was going to use a batch file, but it turns out that nantcontrib has a concat task, for example.

Effeminacy answered 23/3, 2009 at 12:57 Comment(0)
M
1

Use the exec task.

Microreader answered 10/3, 2009 at 18:53 Comment(5)
You may also have to use cmd /c yourbatch.cmd since nant probably doesn't know which program executes batch files.Teishateixeira
@Joey: The cmd /c hint is crucial; only like that does it become possible to run something of which you don't know yet whether it is an exe or a bat file. If you write an answer with that, I will upvote it.Liverwort
@Joey: Wait, with cmd /c in place, NAnt will not be able to run the same build script on Linux, right?Liverwort
It'd be difficult to use the exact same script on Linux anyway, so just distinguish by platform in two different tasks.Teishateixeira
@Joey: I'm not sure what would be difficult about that, but I've asked about the issue in a separate question.Liverwort

© 2022 - 2024 — McMap. All rights reserved.