Nag*_*agg 8 cruisecontrol.net nant
我的目标是用命令"git describe"的输出来填充属性.我有一个属性:
<property name="build.version" value = ""/>
Run Code Online (Sandbox Code Playgroud)
我想用以下命令的输出填充它:git describe
我试过了:
<exec program='${git.executable}' outputproperty='build.version'>
<arg value='describe' />
</exec>
Run Code Online (Sandbox Code Playgroud)
但与Ant不同,NAnt不支持outputproperty :(仅输出(到文件).
你是对的.您具有resultproperty保存退出代码和output属性的属性以重定向输出.
为什么不通过loadfile任务重定向输出并加载文件:
<target name="foo">
<property
name="git.output.file"
value="C:\foo.txt" />
<exec program="${git.executable}" output="${git.output.file}">
<arg value="describe" />
</exec>
<loadfile
file="${git.output.file}"
property="git.output" />
</target>
Run Code Online (Sandbox Code Playgroud)
小智 5
使用trim,你可以在最后摆脱回车符.例如,在上面的示例中,在末尾添加一条线来修剪字符串
<target name="foo">
<property
name="git.output.file"
value="C:\foo.txt" />
<exec program="${git.executable}" output="${git.output.file}">
<arg value="describe" />
</exec>
<loadfile
file="${git.output.file}"
property="git.output" />
<property name="git.ouput.trimmed" value="${string::trim(git.output)}" />
</target>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3759 次 |
| 最近记录: |