Commandline is documented as: The command-line arguments for the program. The syntax is:
<exec program="ruby" commandline="script.rb arg1 arg2 arg3"/>Using exec and commandline should be the same as executing the following statement at a command line.
$ ruby script.rb arg1 arg2 arg3
Arg is documented as: The command-line arguments for the external program. The syntax is:
<exec program="ruby">Using exec and arg should be the same as executing the following statement at a command line.
<arg value="script.rb"/>
<arg value="arg1"/>
<arg value="arg2"/>
<arg value="arg3"/>
</exec>
$ ruby "script.rb" "arg1" "arg2" "arg3"
Obviously, the difference is that arg adds quotes around the arguments. This may seem like a small issue, but I've seen time wasted on this minor difference. The most common problematic scenario occurs when someone tries to combine multiple args into one arg tag.
<exec program="ruby">The problem with the above example is that it is the same as executing the following statement at a command line.
<arg value="script.rb arg1 arg2 arg3"/>
</exec>
$ ruby "script.rb arg1 arg2 arg3"
This won't work in a build and at the command line it would produce:
ruby: No such file or directory -- script.rb arg1 arg2 arg3 (LoadError)
Using commandline or arg is likely a matter of personal preference as long as you are educated on the differences.
I want mix an argument with quotes and arguments without quotes.
ReplyDeleteSomething like this:
exec program="devenv"
arg file="G:/Mi Sourcesafe/latest/GENESYSENGINE/Src/System/Chamaleon/Chamaleon.vcproj"
arg value="/build"
arg value="Release"
It can't works. Help, please.
If you use a single quote as the string delimiter for the commandline string, you can use double quotes within the commandline string.
ReplyDeleteFor example:
<exec program="devenv" commandline='"c:/my work/project 1/foo.sln" /build Debug'/>
Sorry abou being late to this party but,
ReplyDeleteWhile this does not work:
<exec program="ruby">
<arg value="script.rb arg1 arg2 arg3"/>
</exec>
Now this should work:
<exec program="ruby">
<arg line="script.rb arg1 arg2 arg3"/>
</exec>
I have used all the different ways to pass command line args, however nant always enclose the whole arguments with 2 brackets, this is what I have:
ReplyDelete<target name="setup">
<exec program="${regexp.exe}" verbose="true">
<arg line="/L (OutputBaseFilename=)(.*) \1 < deploy.iss > temp.iss" />
</exec>
</target>
and this is what I get:
[exec] Starting 'D:\utils\regexp.exe (/L (OutputBaseFilename=)(.*) \1 < deploy.iss > temp.iss)' in 'D:\'
[exec] Too many command line parameters.
Could you help please?