title: Build visual studio solution from code
body: <p>I'm writing a console application to get a solution from a tfs server, build it and publish on iis, but I'm stuck at building...</p>
  
  <p>I found this code, which works like a charm</p>
  
  <pre><code>public static void BuildProject()
  {
      string solutionPath = Path.Combine(@"C:\MySolution\Common\Common.csproj");
  
      List&lt;ILogger&gt; loggers = new List&lt;ILogger&gt;();
      loggers.Add(new ConsoleLogger());
      var projectCollection = new ProjectCollection();
      projectCollection.RegisterLoggers(loggers);
      var project = projectCollection.LoadProject(solutionPath);
      try
      {
          project.Build();
      }
      finally
      {
          projectCollection.UnregisterAllLoggers();
      }
  }
  </code></pre>
  
  <p>but my solution it's pretty big and contains multiple projects which depends from each other (e.g. project A has a reference to project B)</p>
  
  <p>how to get the correct order to build each project?
  is there a way to build the entire solution from the .sln file?</p>