title: How to get Build output, error list, when running Project.Build() in a custom build task?
body: <p><strong>Environment:</strong></p>
  
  <p>C# projects, Visual studio 2008, C#, .Net 3.5, MSBuild</p>
  
  <p><strong>Objective:</strong></p>
  
  <p>Run my own custom build task for my C# projects, and based on the platform (Soln configuration platform), I do some manipulations to the Project object itself before build. Like setting BuildAction to EmbeddedResource etc.</p>
  
  <p>Once that's done I call <code>Project.Build()</code>. I don't want to use the Project object on the GlobalEngine, because it is going to mark the file dirty (and checkout from TFS), once you modify the Project object in anyway.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>Because I am using my own instance of the Engine, and Project, I am not able to direct the build output, errors to VS. I only get a bool out of <code>Project.Build()</code>.
  I don't find any events I could hook up to that can allow access to <code>BuildErrorEventArgs</code> and things like that. I know I can use <code>Log.LogErrorEvent()</code> to log messages to VS error list. But I need to get the build output itself first to do that.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>// Execute method in my custom build task class, derives from a BaseTask class
  public override bool Execute()
  {
  Engine engine = new Engine();
  Project project = new Project(engine);
  project.Load(ProjectName);
  Log.LogMessage(Microsoft.Build.Framework.MessageImportance.High, "Got the Project");
  // Set the project's DefaultTargets to "Build" to be able to build with CSharp targets
  project.DefaultTargets = "Build";
  IsBuilt = project.Build(); // Isbuilt bool is a property in my BaseTask class
  // Here's where I want to get Build output and direct it to VS output window and errorlist window
  
  engine.Shutdown();
  return base.Execute();
  }
  </code></pre>