public RunInfo[] PreProcess(RunInfo[] details)
 {
     var switcher = new MSTestSwitcharoo(Environment.OSVersion.Platform,
                                         Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
     details
         .Where(x => x.Project != null).ToList()
         .ForEach(x =>
                      {
                          if (File.Exists(x.TemporaryBuildProject))
                          {
                              var project = File.ReadAllText(x.TemporaryBuildProject);
                              if (switcher.IsGuyInCloset(project))
                                  File.WriteAllText(x.TemporaryBuildProject, switcher.PerformSwitch(project));
                          }
                          else
                          {
                              var project = File.ReadAllText(x.Project.Key);
                             if (switcher.IsGuyInCloset(project))
                             {
                                 var tmpProject = getTempProject(x.Project.Key);
                                 // We can do this because we know they are ordered in the right order
                                 _tmpProjects.ForEach(y => 
                                     project = project
                                         .Replace("\\" + Path.GetFileName(getOriginalProject(y)), "\\" + Path.GetFileName(y))
                                         .Replace("\"" + Path.GetFileName(getOriginalProject(y)), "\"" + Path.GetFileName(y)));
                                 File.WriteAllText(tmpProject, switcher.PerformSwitch(project));
                                 _tmpProjects.Add(tmpProject);
                                 x.BuildTemporaryProject(tmpProject);
                             }
                          }
                      });
     return details;
 }
        public bool Build(string[] originalProjects, RunInfo[] projectList, RunReport runReport, Func<bool> exit)
        {
            _exit = exit;
            projectList = preProcessBuildRun(projectList);
            if (projectList.Where(x => x.ShouldBeBuilt).Select(x => x).Count() == 0)
                return true;

            Debug.WriteInfo("Running builds");
            BuildRunResults results = null;
            if (_configuration.ShouldBuildSolution)
                results = buildSolution(projectList, runReport);
            else
                results = buildProjects(originalProjects, projectList, runReport);
            postProcessBuildRuns(projectList, ref runReport);
            return results == null;
        }
 public RunInfo[] PreProcess(RunInfo[] details)
 {
     if (_isActive && _files != null)
     {
         _configuration.OverrideSolution(_files.Solution.Tempfile);
         details
             .Where(x => x.Project != null).ToList()
             .ForEach(x =>
                 {
                     Logger.WriteDebug("Checking for temp projects for " + x.Project.Key);
                     var temp = _files.Files.FirstOrDefault(y => y.Original.Equals(x.Project.Key));
                     if (temp != null)
                     {
                         Logger.WriteDebug("\tFound " + temp.Tempfile);
                         x.BuildTemporaryProject(temp.Tempfile);
                     }
                 });
     }
     return details;
 }
        private BuildRunResults buildSolution(RunInfo[] projectList, RunReport runReport)
        {
            var buildExecutable = _configuration.BuildExecutable(new ProjectDocument(ProjectType.None));
            if (File.Exists(buildExecutable))
            {
                _bus.Publish(new RunInformationMessage(InformationType.Build, _configuration.SolutionToBuild, "", typeof(MSBuildRunner)));

                var buildReport = _buildRunner.RunBuild(_configuration.SolutionToBuild, projectList.Where(p => p.Project.Value.RequiresRebuild).Count() > 0, buildExecutable, () => { return _exit(); });
                buildReport = postProcessBuildReports(buildReport);
                var succeeded = buildReport.ErrorCount == 0;
                runReport.AddBuild(_configuration.WatchToken, buildReport.TimeSpent, succeeded);
                _bus.Publish(new BuildRunMessage(buildReport));
                if (succeeded)
                    return null;
                else
                    return buildReport;
            }
            return null;
        }