public void WriteBuildFile(BuildInfo bi)
 {
     buildMasterXml bmx = new buildMasterXml(bi);
     string outputDir = ConfigurationManager.AppSettings["outputDir"];
     WriteFile(outputDir + @"autobuild.master.xml", bmx.TransformText(), null, false);
     foreach (var ps in bi.ProjectSetsToBuild)
     {
         buildBatchTemplate bbt = new buildBatchTemplate(bi, ps);
         WriteFile(outputDir + @"autobuild." + ps.BuildKeyName + ".xml", bbt.TransformText(), ps, false);
     }
 }
        public BuildInfo GenerateBuild(List<ProjectInfo> pis, string buildFileRelativeOffset)
        {
            BuildInfo bi = new BuildInfo(buildFileRelativeOffset);
            List<ProjectInfo> accountedProjects = new List<ProjectInfo>();

            // First find projects with no references in anything else in this list.
            int counter = 0;
            ProjectSet lastPs = null;
            while (accountedProjects.Count != pis.Count)
            {
                var nextBatch = FindNextBatch(pis, accountedProjects);
                var newPs = new ProjectSet(nextBatch, string.Format("Batch {0}", counter++));
                if (lastPs != null)
                    newPs.DependsOn = lastPs;
                lastPs = newPs;
                bi.ProjectSetsToBuild.Add(newPs);
                accountedProjects.AddRange(nextBatch);

            }

            return bi;
        }