title: Building programmatically a project
body: <p>I need to build a project programmatically for a .csproj I am creating on the fly.
  While searching Google I found the classes and API provided by the MS for the MSBuild Engine. With that information, I create a process which executes msbuild.exe and then reads the output, but now I want to use the namespace <code>Microsoft.Build.Execution</code> to build the project. This is my program:</p>
  
  <pre><code>public class Compiler
  {
     private static string locationOfMSBuilldEXE = "";
     public static void Build(string msbuildFileName)
     {
         BuildManager manager = BuildManager.DefaultBuildManager;
  
         ProjectInstance projectInstance = new ProjectInstance(msbuildFileName);
         var result = manager.Build(new BuildParameters() 
                  {
                      DetailedSummary = true
                  }, 
                  new BuildRequestData(projectInstance, new string[] { "Build" }));
         var buildResult = result.ResultsByTarget["Build"];
         var buildResultItems = buildResult.Items;
  
         string s = "";
     }
  }
  </code></pre>
  
  <p>The results show that this is building fine, but I need to know the detailed output from the compile and how to view it. It would be really helpful if someone can give me link to a good tutorial or a book on MSBuild.</p>