Skip to content

Instantly share code, notes, and snippets.

@benerdin
Last active December 29, 2015 00:59
Show Gist options
  • Select an option

  • Save benerdin/7589819 to your computer and use it in GitHub Desktop.

Select an option

Save benerdin/7589819 to your computer and use it in GitHub Desktop.
Example of how to use nAnt's <foreach> and <xmlpoke> tasks.
<!--
Given the following files in C:\
* app.1.config
* app.2.config
* app.3.config
* file.txt
This task will perform 3 iterations and set ${filename} to the following:
* C:\app.1.config
* C:\app.2.config
* C:\app.3.config
-->
<foreach item="File" property="filename">
<in>
<items>
<include name="C:\*.config" />
</items>
</in>
<do>
<xmlpoke file="${filename}"
xpath="/configuration/appSettings/add[@key='AppSettingKey']/@value"
value="My Value" />
</do>
</foreach>
<!-- Compare value of variables -->
<if test="${variable1 == variable2}">
</if>
<if test="${property::exists('variableName')}">
</if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment