Пример #1
0
        static void DumpProjectSlnx(SlnxHandler slnx)
        {
            var emptySlnx         = new Slnx.Generated.SlnXType();
            var projectReferences = new List <Slnx.Generated.ProjectType>();

            foreach (var csProj in slnx.Projects)
            {
                var project = new Slnx.Generated.ProjectType();
                project.name = csProj.Name;

                if (!string.IsNullOrEmpty(csProj.Container) && csProj.Container != CsProject.TestContainerName)
                {
                    project.container = csProj.Container;
                }
                if (csProj.AllPackageReferences.Any())
                {
                    var references = new List <string>();
                    references.AddRange(csProj.AllPackageReferences.Select(x => x.Identity.Id));
                    project.@ref = references.ToArray();
                }
                projectReferences.Add(project);
            }
            if (projectReferences.Any())
            {
                emptySlnx.project = projectReferences.ToArray();

                var xmlSer = new XmlSerializer(typeof(SlnXType));
                var xml    = new StringBuilder();
                using (var stream = new StringWriter(xml))
                {
                    xmlSer.Serialize(stream, emptySlnx);
                }
                string content = XDocument.Parse(xml.ToString()).ToString();
                _fileWriter.WriteAllText(Path.Combine(slnx.SlnxDirectory, "Projects.slnx"), content.ToString());
            }
        }