SolutionSection GenerateProjectConfigurationSection(ISolution solution) { SolutionSection section = new SolutionSection("ProjectConfigurationPlatforms", "postSolution"); foreach (var project in solution.AllItems.OfType <IProject>()) { foreach (var configuration in solution.ConfigurationNames) { foreach (var platform in solution.PlatformNames) { var solutionConfig = new ConfigurationAndPlatform(configuration, platform); var projectConfig = project.ConfigurationMapping.GetProjectConfiguration(solutionConfig); string key = GuidToString(project.IdGuid) + "." + solutionConfig; string value = projectConfig.Configuration + "|" + MSBuildInternals.FixPlatformNameForSolution(projectConfig.Platform); section.Add(key + ".ActiveCfg", value); if (project.ConfigurationMapping.IsBuildEnabled(solutionConfig)) { section.Add(key + ".Build.0", value); } if (project.ConfigurationMapping.IsDeployEnabled(solutionConfig)) { section.Add(key + ".Deploy.0", value); } } } } return(section); }
public void GlobalSection() { SolutionSection section = new SolutionSection("ProjectConfigurationPlatforms", "postSolution"); section.Add("{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.ActiveCfg", "Debug|Any CPU"); section.Add("{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg", "Release|Any CPU"); StringWriter w = new StringWriter(); new SolutionWriter(w).WriteGlobalSection(section); Assert.AreEqual("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution" + w.NewLine + "\t\t{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.ActiveCfg = Debug|Any CPU" + w.NewLine + "\t\t{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg = Release|Any CPU" + w.NewLine + "\tEndGlobalSection" + w.NewLine , w.ToString()); }
public void WriteSolutionItem(ISolutionItem item) { ISolutionFolder folder = item as ISolutionFolder; IProject project = item as IProject; if (folder != null) { WriteProjectHeader(ProjectTypeGuids.SolutionFolder, folder.Name, folder.Name, folder.IdGuid); // File items are represented as nodes in the tree, but they're actually // saved as properties on their containing folder. SolutionSection section = new SolutionSection("SolutionItems", "preProject"); foreach (var file in folder.Items.OfType <ISolutionFileItem>()) { string location = FileUtility.GetRelativePath(basePath, file.FileName); section.Add(location, location); } WriteProjectSection(section); writer.WriteLine("EndProject"); } else if (project != null) { string location = FileUtility.GetRelativePath(basePath, project.FileName); WriteProjectHeader(project.TypeGuid, project.Name, location, project.IdGuid); foreach (var section in project.ProjectSections) { WriteProjectSection(section); } writer.WriteLine("EndProject"); } }
internal void AddItemToSolution(string name) { if (ItemExistsInSolution(name)) { return; } SolutionSectionItem item = GetNonPersistedSolutionItem(name); nonPersistedSolutionItems.Remove(item); SD.SolutionSection section = GetOrCreateExtensibilityGlobalsSection(); section.Add(item.Name, item.Value); solution.Save(); }
SolutionSection GenerateSolutionConfigurationSection(IConfigurable solution) { SolutionSection section = new SolutionSection("SolutionConfigurationPlatforms", "preSolution"); foreach (var config in solution.ConfigurationNames) { foreach (var platform in solution.PlatformNames) { string key = config + "|" + platform; section.Add(key, key); } } return(section); }
void ReadSectionEntries(SolutionSection section) { while (currentLine != null) { int pos = currentLine.IndexOf('='); if (pos < 0) { break; // end of section } string key = currentLine.Substring(0, pos).Trim(); string value = currentLine.Substring(pos + 1).Trim(); section.Add(key, value); NextLine(); } }
SolutionSection GenerateNestingSection(ISolution solution) { SolutionSection section = new SolutionSection("NestedProjects", "preSolution"); foreach (var item in solution.AllItems) { if (item is ISolutionFileItem) { continue; // file items are a special case as they're saved in their own section } if (item.ParentFolder != solution) { section.Add(GuidToString(item.IdGuid), GuidToString(item.ParentFolder.IdGuid)); } } return(section); }