Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass 2 parameters to Nant script?

I have to write an Nant script that will accept 2 parameters on the command line. The first is just an option and has the following format: -myOption. The second one needs to be wrapped in quotes: "some value with space".

e.g. -myOption "this value"

I am new to Nant so I have unsuccessful so far and don't know how to output the command to debug.

This is what I have so far:

<target name="Build" depends="SetupConfig">
<exec workingdir="${refactory.basedir}" program="${exe.name.mfg.factory}" basedir="${refactory.basedir}" commandline="-myOption:">  
 <arg>${refactory.clientconfig}</arg>   
</exec>

I am attempting to create the command using the "commandline"' attribute and the args nested element. The args element is supposed to provide qoutes.

Can some tell me how this should look? Thanks.

like image 689
Nick Avatar asked Feb 16 '10 14:02

Nick


2 Answers

I need to confess, looking at your code snippet it's not completely clear to me, what You are trying to achieve.

Anyway, this is how you pass two arguments to a NAnt script (what You're claiming for regarding to the question's title):

Given a NAnt script example.project.build with following content:

<?xml version="1.0"?>
<project name="example.project" default="example.target" basedir=".">
  <target name="example.target">
    <echo message="${arg.option}" />
    <echo message="${arg.whitespace}" />
  </target>
</project>

... you would call

nant -buildfile:example.project.build -D:arg.option=foo -D:arg.whitespace="bar and bar"

... to execute script example.project.build and pass arguments arg.option and arg.whitespace to it.

like image 155
The Chairman Avatar answered Oct 01 '22 23:10

The Chairman


Try this:

<target name="Build" depends="SetupConfig">
<exec workingdir="${refactory.basedir}" program="${exe.name.mfg.factory}"  basedir="${refactory.basedir}">
    <arg value="-myOption" />
    <arg value="${refactory.clientconfig}" />
</exec>

For more information view Nant Exec task documentation.

like image 28
Arnold Zokas Avatar answered Oct 02 '22 00:10

Arnold Zokas