--- C:\--\a\Task.cs	Tue Dec 30 09:54:18 2003
+++ E:\src\extern\nant\src\NAnt.Core\Task.cs	Thu Jan 08 12:12:05 2004
@@ -25,10 +25,13 @@
 using System.Globalization;
 using System.Reflection;
 using System.Xml;
+using System.Xml.XPath;
 
 using NAnt.Core.Attributes;
 using NAnt.Core.Util;
 
+using Bamboo.Prevalence.XPath;
+
 namespace NAnt.Core {
     /// <summary>
     /// Provides the abstract base class for tasks.
@@ -38,6 +41,34 @@
     /// </remarks>
     [Serializable()]
     public abstract class Task : Element {
+
+		public class ResultElement : Element {
+			#region Private Instance Fields
+
+			private string _property = "";
+			private string _xpath    = "";
+
+			#endregion Private Instance Fields
+
+			#region Public Instance Properties
+
+			[TaskAttribute("taskoutput", Required=true)]
+        	[StringValidator(AllowEmpty=false)]
+			public string XPath {
+				get { return _xpath; }
+				set { _xpath = value; }
+			}
+			
+			[TaskAttribute("property", Required=true)]
+        	[StringValidator(AllowEmpty=false)]
+			public string Property {
+				get { return _property; }
+				set { _property = value; }
+			}
+
+			#endregion Public Instance Properties
+		}
+    			
         #region Private Static Fields
 
         private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@@ -50,11 +81,18 @@
         private bool _verbose = false;
         private bool _ifDefined = true;
         private bool _unlessDefined = false;
+        private ResultElement _resultElement;
 
         #endregion Private Instance Fields
 
         #region Public Instance Properties
 
+        [BuildElement("result")]
+        public ResultElement Result {
+            get { return _resultElement; }
+            set { _resultElement = value; }
+        }
+		
         /// <summary>
         /// Determines if task failure stops the build, or is just reported. 
         /// The default is <see langword="true" />.
@@ -141,6 +179,10 @@
                 try {
                     Project.OnTaskStarted(this, new BuildEventArgs(this));
                     ExecuteTask();
+					if(Result!=null) {
+						FillResult(Result);
+					}
+						
                 } catch (Exception ex) {
                     logger.Error(string.Format(
                         CultureInfo.InvariantCulture,
@@ -366,5 +408,25 @@
         protected abstract void ExecuteTask();
 
         #endregion Protected Instance Methods
+
+        #region Private Instance Methods
+
+		private void FillResult(ResultElement res) {
+            string contents = null;
+			
+			Project.Log(Level.Info,"result property "+res.Property+" called via xpath "+res.XPath);
+			
+			XPathObjectNavigator nav = new XPathObjectNavigator(this);
+			XPathNodeIterator i = nav.Select(res.XPath);
+
+			i.MoveNext();
+       		contents = i.Current.Value;
+						
+			Project.Log(Level.Info,"result property "+res.Property+" = "+contents);
+            //return contents;
+            Project.Properties[res.Property] = contents;
+		}
+		
+        #endregion Private Instance Methods
     }
-}
\ No newline at end of file
+}
