Serialize( string solutionPath) { var ProjectTypeGuid = System.Guid.Parse("8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942"); var SolutionFolderGuid = System.Guid.Parse("2150E333-8FDC-42A3-9474-1A3956D46DE8"); var content = new System.Text.StringBuilder(); var visualCMeta = Bam.Core.Graph.Instance.PackageMetaData <VisualC.MetaData>("VisualC"); content.AppendFormat(@"Microsoft Visual Studio Solution File, Format Version {0}", visualCMeta.SolutionFormatVersion); content.AppendLine(); var configs = new Bam.Core.StringArray(); foreach (var project in this.Projects) { var relativeProjectPath = Bam.Core.RelativePathUtilities.GetPath(project.ProjectPath, solutionPath); content.AppendFormat("Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\"", ProjectTypeGuid.ToString("B").ToUpper(), System.IO.Path.GetFileNameWithoutExtension(project.ProjectPath), relativeProjectPath, project.GuidString); content.AppendLine(); content.AppendLine("EndProject"); foreach (var config in project.Configurations) { configs.AddUnique(config.Value.FullName); } } foreach (var folder in this.SolutionFolders) { var folderPath = folder.Value.Path; var folderGuid = folder.Value.GuidString; content.AppendFormat("Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\"", SolutionFolderGuid.ToString("B").ToUpper(), folderPath, folderPath, folderGuid); content.AppendLine(); content.AppendLine("EndProject"); } content.AppendLine("Global"); content.AppendLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); foreach (var config in configs) { // TODO: I'm sure these are not meant to be identical, but I don't know what else to put here content.AppendFormat("\t\t{0} = {0}", config); content.AppendLine(); } content.AppendLine("\tEndGlobalSection"); content.AppendLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); foreach (var project in this.Projects) { var guid = project.GuidString; var thisProjectConfigs = new Bam.Core.StringArray(); // write the configurations for which build steps have been defined foreach (var config in project.Configurations) { var configName = config.Value.FullName; content.AppendFormat("\t\t{0}.{1}.ActiveCfg = {1}", guid, configName); content.AppendLine(); content.AppendFormat("\t\t{0}.{1}.Build.0 = {1}", guid, configName); content.AppendLine(); thisProjectConfigs.AddUnique(configName); } // now cater for any configurations that the project does not support var unsupportedConfigs = configs.Complement(thisProjectConfigs) as Bam.Core.StringArray; foreach (var uConfig in unsupportedConfigs) { // a missing "XX.YY.Build.0" line means not configured to build // also, the remapping between config names seems a little arbitrary, but seems to work // might be related to the project not having an ProjectConfiguration for the unsupported config content.AppendFormat("\t\t{0}.{1}.ActiveCfg = {2}", guid, uConfig, thisProjectConfigs[0]); content.AppendLine(); } } content.AppendLine("\tEndGlobalSection"); content.AppendLine("\tGlobalSection(SolutionProperties) = preSolution"); content.AppendLine("\t\tHideSolutionNode = FALSE"); content.AppendLine("\tEndGlobalSection"); if (this.SolutionFolders.Count() > 0) { content.AppendLine("\tGlobalSection(NestedProjects) = preSolution"); foreach (var folder in this.SolutionFolders) { folder.Value.Serialize(content, 2); } content.AppendLine("\tEndGlobalSection"); } content.AppendLine("EndGlobal"); return(content); }