Beispiel #1
0
        public void Dump(TextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.WriteLine("Projects");

            foreach (var proj in projects)
            {
                writer.WriteLine($"\t{ProjectTypeGuids.GetNameIfAvailable (proj.ProjectTypeGuids)} {proj.Path}");
            }

            writer.WriteLine();
            writer.WriteLine("SolutionConfigurationPlatform");
            foreach (var plat in solution_configuration_platforms)
            {
                writer.WriteLine('\t' + plat);
            }

            writer.WriteLine();
            writer.WriteLine("Solution Folders:");
            foreach (var nest in NestedProjects)
            {
                var folder = ProjectGuidToName(nest.Key);
                writer.WriteLine("\t" + folder);
                foreach (var n in nest)
                {
                    var item = ProjectGuidToName(n.Item);
                    writer.WriteLine("\t\t" + item);
                }
            }

            writer.WriteLine();
            writer.WriteLine("ProjectConfigurationPlatforms");
            foreach (var cfgGroup in ProjectConfigurationPlatforms)
            {
                var deftpl  = ProjectConfigurationPlatformTemplate.CreateTemplateFor("all", solution_configuration_platforms);
                var matches = deftpl.Matches(cfgGroup);
                var pattern = deftpl.Matches(cfgGroup) ? "all" : null;
                writer.WriteLine("\t" + GetProjectName(cfgGroup.First()) + " : " + pattern);
                if (pattern != null)
                {
                    continue;
                }
                foreach (var cfg in cfgGroup)
                {
                    writer.WriteLine($"\t\tCFG#{SolutionConfigurationIndexOf (cfg)} / {cfg.Property} / {ProjectConfigurationPlatform.GetValueIfAvailable (cfg.ConfigurationValue)}");
                }
            }

            writer.WriteLine();

            foreach (var sec in other_global_sections)
            {
                writer.WriteLine($"OTHER SECTION: {sec.Name} ({sec.Type})");
                writer.WriteLine(sec.Value);
            }
        }
Beispiel #2
0
        public void SaveXml(string outputXmlFile)
        {
            var output = new XDocument();

            output.Add(new XElement("solution"));

            var projectsElement = new XElement("projects");

            output.Root.Add(new XComment("Project name is omitted if it is identical to the file name (without extension)."));
            output.Root.Add(projectsElement);
            foreach (var proj in projects)
            {
                var file = proj.Path.Replace('\\', Path.DirectorySeparatorChar);
                if (File.Exists(Path.Combine(base_directory, file)))
                {
                    projectsElement.Add(new XElement("project",
                                                     Path.GetFileNameWithoutExtension(file) != proj.Name ? new XAttribute("name", proj.Name) : null,
                                                     new XAttribute("file", file)
                                                     ));
                }
            }

            var configsElement = new XElement("config-names-for-solution");

            output.Root.Add(configsElement);
            foreach (var plat in solution_configuration_platforms)
            {
                configsElement.Add(new XElement("config", new XAttribute("name", plat)));
            }

            var foldersElement = new XElement("solution-folders");

            output.Root.Add(foldersElement);

            foreach (var nest in NestedProjects)
            {
                var folder        = ProjectGuidToName(nest.Key);
                var folderElement = new XElement("folder", new XAttribute("name", folder));
                foldersElement.Add(folderElement);
                foreach (var n in nest)
                {
                    var item = ProjectGuidToName(n.Item);
                    folderElement.Add(new XElement("project", new XAttribute("name", item)));
                }
            }

            var pcpElement = new XElement("project-config-properties");

            output.Root.Add(new XComment("Value 'all' indicates that the project contains `ActiveCfg` and `Build.0` properties for all configs."));
            output.Root.Add(pcpElement);
            foreach (var cfgGroup in ProjectConfigurationPlatforms)
            {
                var deftpl  = ProjectConfigurationPlatformTemplate.CreateTemplateFor("all", solution_configuration_platforms);
                var pattern = deftpl.Matches(cfgGroup) ? "all" : null;
                var p       = new XElement("project", new XAttribute("name", ProjectGuidToName(cfgGroup.Key)));
                if (pattern != null)
                {
                    p.Add(new XAttribute("pattern", pattern));
                }
                else
                {
                    foreach (var cfg in cfgGroup)
                    {
                        p.Add(new XElement("config-platform",
                                           new XAttribute("config", cfg.SolutionConfigurationName),
                                           new XAttribute("property", cfg.Property),
                                           new XAttribute("value", cfg.ConfigurationValue)
                                           ));
                    }
                }
                pcpElement.Add(p);
            }

            var otherElement = new XElement("other-global-sections");

            output.Root.Add(otherElement);
            foreach (var other in other_global_sections)
            {
                otherElement.Add(new XElement("section", new XAttribute("name", other.Name), new XAttribute("type", other.Type), new XText(other.Value)));
            }

            output.Save(outputXmlFile);
        }