Is there a NAnt task that will echo out all property names and values that are currently set during a build? Something equivalent to the Ant echoproperties task maybe?
Try this snippet:
<project>
<property name="foo" value="bar"/>
<property name="fiz" value="buz"/>
<script language="C#" prefix="util" >
<code>
<![CDATA[
public static void ScriptMain(Project project)
{
foreach (DictionaryEntry entry in project.Properties)
{
Console.WriteLine("{0}={1}", entry.Key, entry.Value);
}
}
]]>
</code>
</script>
</project>
You can just save and run with nant.
And no, there isn't a task or function to do this for you already.
I tried the solutions suggested by Brad C, but they did not work for me (running Windows 7 Profession on x64 with NAnt 0.92). However, this works for my local configuration:
<target name="echo-properties" verbose="false" description="Echo property values" inheritall="true">
<script language="C#">
<code>
<![CDATA[
public static void ScriptMain(Project project)
{
System.Collections.SortedList sortedByKey = new System.Collections.SortedList();
foreach(DictionaryEntry de in project.Properties)
{
sortedByKey.Add(de.Key, de.Value);
}
NAnt.Core.Tasks.EchoTask echo = new NAnt.Core.Tasks.EchoTask();
echo.Project = project;
foreach(DictionaryEntry de in sortedByKey)
{
if(de.Key.ToString().StartsWith("nant."))
{
continue;
}
echo.Message = String.Format("{0}: {1}", de.Key,de.Value);
echo.Execute();
}
}
]]>
</code>
</script>
</target>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With