如何将2个参数传递给Nant脚本?

Nic*_*ick 6 .net ant nant build-automation

我必须编写一个Nant脚本,它将在命令行上接受2个参数.第一个只是一个选项,具有以下格式:-myOption.第二个需要用引号括起来:"有些空间值".

例如-myOption"this value"

我是Nant的新手,所以到目前为止我还没有成功,也不知道如何输出命令进行调试.

这是我到目前为止:

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

我试图使用"命令行"属性和args嵌套元素创建命令.args元素应该提供qoutes.

有人可以告诉我这看起来应该怎样?谢谢.

The*_*man 29

我需要承认,看看你的代码片段,我并不完全清楚你想要实现的目标.

无论如何,这是你将两个参数传递给NAnt脚本的方式(你要求的关于问题标题的内容):

给定example.project.build具有以下内容的NAnt脚本:

<?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>
Run Code Online (Sandbox Code Playgroud)

......你会打电话

nant -buildfile:example.project.build -D:arg.option=foo -D:arg.whitespace="bar and bar"
Run Code Online (Sandbox Code Playgroud)

...执行脚本example.project.build并传递参数arg.optionarg.whitespace它.


Arn*_*kas 2

尝试这个:

<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>
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请查看Nant Exec 任务文档