Search code examples
cruisecontrol.netnant

How to assign exec's output to a property in NAnt


My aim is to fill property with output of command "git describe". I have a property:

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

And I want to fill it with output of the following command: git describe

I tried:

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

but unlike the Ant, NAnt doesn't support outputproperty :( only output (to file).


Solution

  • You're right. You have resultproperty attribute to hold the exit code and output attribute to redirect the output.

    Why don't you redirect the output and load the file afterwards via loadfile task:

    <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>