? NAntAddin.patch
? NAntAddinAPI.xml
? bin/Debug
? bin/Release
Index: NAntAddin.cs
===================================================================
RCS file: /cvsroot/nantcontrib/NAntContrib/Tools/VSNetAddin/NAntAddin.cs,v
retrieving revision 1.1
diff -u -3 -r1.1 NAntAddin.cs
--- NAntAddin.cs	15 Jul 2002 16:42:50 -0000	1.1
+++ NAntAddin.cs	14 Sep 2003 06:19:19 -0000
@@ -21,6 +21,7 @@
 using System;
 using System.Xml;
 using System.Text;
+using System.IO;
 using Extensibility;
 using System.Drawing;
 using System.Threading;
@@ -31,7 +32,7 @@
 using System.Runtime.InteropServices;
 
 using stdole;
-using SourceForge.NAnt;
+using NAnt.Core;
 using VSUserControlHostLib;
 using NAnt.Contrib.NAntAddin.Nodes;
 using NAnt.Contrib.NAntAddin.Controls;
@@ -832,7 +833,6 @@
 		{
 			outputWindow = (OutputWindow)application.Windows.Item(Constants.vsWindowKindOutput).Object;
 			buildOutputWindow = outputWindow.OutputWindowPanes.Add("NAnt Build");
-			Log.Listeners.Add(new AddinLogListener(buildOutputWindow));
 		}
 
 		/// <summary>
@@ -1287,36 +1287,103 @@
 	/// Logs NAnt build log messages to 
 	/// a Visual Studio.NET Output Window.
 	/// </summary>
-	internal class AddinLogListener : LogListener
+	internal class AddinLogListener : IBuildListener
 	{
 		private OutputWindowPane buildOutputWindow;
 
-		/// <summary>
-		/// Creates a new Addin Log Listener.
-		/// </summary>
-		/// <param name="BuildOutputWindow">The Output Pane to write messages to</param>
-		internal AddinLogListener(OutputWindowPane BuildOutputWindow)
-		{
-			buildOutputWindow = BuildOutputWindow;
-		}
-
-		/// <summary>
-		/// Occurs when a Message is written to the Log.
-		/// </summary>
-		/// <param name="message">The Message that was written</param>
-		public override void Write(string message)
-		{
-			buildOutputWindow.OutputString(message);
-		}
-
-		/// <summary>
-		/// Occurs when a Line is written to the Log.
-		/// </summary>
-		/// <param name="line">The Line that was written.</param>
-		public override void WriteLine(string line)
-		{
-			buildOutputWindow.OutputString("\n" + line);
-		}
+        /// <summary>
+        /// Creates a new Addin Log Listener.
+        /// </summary>
+        /// <param name="BuildOutputWindow">The Output Pane to write messages to</param>
+        internal AddinLogListener(OutputWindowPane BuildOutputWindow)
+        {
+            buildOutputWindow = BuildOutputWindow;
+        }
+
+        /// <summary>
+        /// Signals that a build has started.
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="e">A <see cref="BuildEventArgs" /> object that contains the event data.</param>
+        /// <remarks>
+        /// This event is fired before any targets have started.
+        /// </remarks>
+        void IBuildListener.BuildStarted(object sender, BuildEventArgs e)
+        {
+        }
+
+        /// <summary>
+        /// Signals that the last target has finished.
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="e">A <see cref="BuildEventArgs" /> object that contains the event data.</param>
+        /// <remarks>
+        /// This event will still be fired if an error occurred during the build.
+        /// </remarks>
+        void IBuildListener.BuildFinished(object sender, BuildEventArgs e)
+        {
+            if (e.Exception == null)
+            {
+                buildOutputWindow.OutputString("\nBUILD SUCCEEDED\n");
+            }
+            else
+            {
+                buildOutputWindow.OutputString("\nBUILD FAILED\n\n" + 
+                    e.Exception.ToString());
+            }
+        }
+
+        /// <summary>
+        /// Signals that a target has started.
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="e">A <see cref="BuildEventArgs" /> object that contains the event data.</param>
+        void IBuildListener.TargetStarted(object sender, BuildEventArgs e)
+        {
+        }
+
+        /// <summary>
+        /// Signals that a target has finished.
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="e">A <see cref="BuildEventArgs" /> object that contains the event data.</param>
+        /// <remarks>
+        /// This event will still be fired if an error occurred during the build.
+        /// </remarks>
+        void IBuildListener.TargetFinished(object sender, BuildEventArgs e)
+        {
+        }
+
+        /// <summary>
+        /// Signals that a task has started.
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="e">A <see cref="BuildEventArgs" /> object that contains the event data.</param>
+        void IBuildListener.TaskStarted(object sender, BuildEventArgs e)
+        {
+        }
+
+        /// <summary>
+        /// Signals that a task has finished.
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="e">A <see cref="BuildEventArgs" /> object that contains the event data.</param>
+        /// <remarks>
+        /// This event will still be fired if an error occurred during the build.
+        /// </remarks>
+        void IBuildListener.TaskFinished(object sender, BuildEventArgs e)
+        {
+        }
+
+        /// <summary>
+        /// Signals that a message has been logged.
+        /// </summary>
+        /// <param name="sender">The source of the event.</param>
+        /// <param name="e">A <see cref="BuildEventArgs" /> object that contains the event data.</param>
+        void IBuildListener.MessageLogged(object sender, BuildEventArgs e)
+        {
+            buildOutputWindow.OutputString("\n" + e.Message);
+        }
 	}
 
 	/// <summary>
@@ -1369,10 +1436,48 @@
 
 			buildOutputWindow.OutputString("\nExecuting Target(s)...\n");
 
-			SourceForge.NAnt.Project nAntProject = 
-				new SourceForge.NAnt.Project(project.FileName);
-
-			nAntProject.Verbose = project.Verbose;
+			Level level;
+            if (project.Verbose)
+                level = Level.Verbose;
+            else
+                level = Level.Info;
+
+            string location = Assembly.GetExecutingAssembly().Location;
+            if (location != "")
+            {
+                location = Path.GetDirectoryName(location);
+                TypeFactory.ScanDir(location);
+            }
+            
+            NAnt.Core.Project nAntProject = 
+				new NAnt.Core.Project(project.FileName, level);
+
+            if (location != "")
+            {
+                string nAntConfig = Path.Combine(location, "NAnt.exe.config");
+                if (File.Exists(nAntConfig))
+                {
+                    try
+                    {
+                        XmlDocument doc = new XmlDocument();
+                        doc.Load(new XmlTextReader(nAntConfig));
+                        XmlNodeList configNodes = doc.DocumentElement.GetElementsByTagName("nant");
+                        if (configNodes.Count > 0)
+                            nAntProject.ProcessSettings(configNodes [0]);
+                    }
+                    catch(XmlException e)
+                    {
+                        buildOutputWindow.OutputString("Failed to load NAnt.exe.config:\n");
+                        buildOutputWindow.OutputString(e.Message + "\n");
+                    }
+
+                }
+            }
+
+            IBuildListener buildListener = new AddinLogListener(buildOutputWindow);
+            nAntProject.BuildListeners.Add(buildListener);
+            nAntProject.MessageLogged += new BuildEventHandler(buildListener.MessageLogged);
+            nAntProject.BuildFinished += new BuildEventHandler(buildListener.BuildFinished);
 
 			if (target != null)
 			{
@@ -1386,9 +1491,9 @@
 			bool failed = false;
 			try
 			{
-				nAntProject.Run();
+				failed = !nAntProject.Run();
 			}
-			catch (SourceForge.NAnt.BuildException be)
+			catch (NAnt.Core.BuildException be)
 			{
 				buildOutputWindow.Activate();
 				buildOutputWindow.OutputString("\n" + be.Message);
