private Solution RemoveTestProjects(Solution solution) { var projectsToRemove = new List<ProjectId>(); projectsToRemove.AddRange(from p in solution.Projects where p.Name.ToUpper().Contains(TestString) select p.Id); Solution filteredSolution = null; foreach (var project in projectsToRemove) { filteredSolution = solution.RemoveProject(project); } return filteredSolution ?? solution; }