May 29, 2008

Passing arguments to exec

Filed under: Nant — Tags: , , , — @ 1:56 pm

In one of my nant tasks I was expecting arguments through args element node. So I have a task like the following




<property arg1=”c:\temp\dir\” />

<property arg2 = “c:\temp\dir2\” />

<target name=”Pgm” description=”Run pgm.exe”>
     <exec program=”pgm.exe”>
  <arg value='”${arg1}” “${arg2}”‘ />

But when I ran the program, it got only one argument instead of two. Obvious thing you do would be then is to display your command line arguments and this is what I got

c:\temp\dir\” c:\temp\dir2″

as you can see my first part fo the double quotes are gone. So after some trail and error (still didn’t hit the google though) I found out that, if I would change the argument to have two slashes instead of the problem is solved. So the modified arguments would look like the following…

<property arg1=”c:\\temp\\dir\\” />

<property arg2 = “c:\\temp\\dir2\\” />

 Thought of logging it for someone else looking…

Powered by WordPress