10

私の目的は、コマンド「git describe」の出力でプロパティを埋めることです。私は財産を持っています:

<property name="build.version" value = ""/>

そして、次のコマンドの出力を入力したいと思います: git describe

私は試した:

<exec program='${git.executable}' outputproperty='build.version'>
  <arg value='describe' />
</exec>

ただし、Ant とは異なり、NAnt はoutputproperty :( (ファイルへの)出力のみをサポートしていません。

4

2 に答える 2

10

あなたが正しい。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>
于 2013-01-19T08:24:21.293 に答える
6

トリムを使用すると、末尾のキャリッジ リターン文字を取り除くことができます。たとえば、上記の例では、最後に行を追加して文字列をトリミングします

<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>
于 2015-07-07T09:01:49.043 に答える