private string Generate(Solution solution, List <Solution.Configuration> configurations, string solutionPath, string solutionFile, out bool updated) { // Create the target folder (solutions and projects are folders in XCode). string solutionFolder = Util.GetCapitalizedPath(solutionPath + Path.DirectorySeparatorChar + solutionFile + SolutionExtension); Directory.CreateDirectory(solutionFolder); // Main solution file. string solutionFileContentsPath = solutionFolder + Path.DirectorySeparatorChar + SolutionContentsFileName; FileInfo solutionFileContentsInfo = new FileInfo(solutionFileContentsPath); bool projectsWereFiltered; List <Solution.ResolvedProject> solutionProjects = solution.GetResolvedProjects(configurations, out projectsWereFiltered).ToList(); solutionProjects.Sort((a, b) => string.Compare(a.ProjectName, b.ProjectName)); // Ensure all projects are always in the same order to avoid random shuffles // Move the first executable project on top. foreach (Solution.ResolvedProject resolvedProject in solutionProjects) { if (resolvedProject.Configurations[0].Output == Project.Configuration.OutputType.Exe) { solutionProjects.Remove(resolvedProject); solutionProjects.Insert(0, resolvedProject); break; } } if (solutionProjects.Count == 0) { updated = solutionFileContentsInfo.Exists; if (updated) { File.Delete(solutionFileContentsPath); } return(solutionFolder); } var fileGenerator = new FileGenerator(); fileGenerator.Write(Template.Header); _solutionFolderCache.Clear(); List <SolutionFile> solutionsFiles = solutionProjects.Select(project => { var solutionFileItem = new SolutionFile() { Name = project.ProjectFile, Parent = ParseSolutionFolder(project.SolutionFolder) }; solutionFileItem.RegisterToParent(); return(solutionFileItem); }).ToList(); List <SolutionItem> solutionsItems = solutionsFiles.GroupBy(solutionsItem => solutionsItem.GetRoot()).Select(group => group.Key).ToList(); solutionsItems.Sort((a, b) => string.Compare(a.Name, b.Name)); foreach (var solutionItem in solutionsItems) { //Sort of folders content (solutionItem as SolutionFolder)?.Sort(); WriteSolutionItem(fileGenerator, solutionItem); } fileGenerator.Write(Template.Footer); // Write the solution file updated = _builder.Context.WriteGeneratedFile(solution.GetType(), solutionFileContentsInfo, fileGenerator.ToMemoryStream()); return(solutionFileContentsInfo.FullName); }