//public IEnumerable<XmlTemplateItemBase> GetProjectEntries(string projectFile) //{ // XmlDocument xmlDoc = new XmlDocument(); // using (var fs = File.OpenRead(projectFile)) // { // xmlDoc.Load(fs); // var projectNode = xmlDoc.SelectSingleNode("Project"); // if (projectNode == null) // { // throw new ArgumentNullException(nameof(projectNode), @"Cannot find Project node."); // } // var sdk = projectNode.Attributes["Sdk"]; // var isSdk = sdk != null; // if (isSdk) // { // } // var itemGroupNodes = xmlDoc.DocumentElement.GetElementsByTagName("ItemGroup").Cast<XmlNode>().ToList(); // if (itemGroupNodes.Count == 0 && !isSdk) // { // throw new InvalidDataException($"Template file does not contain ItemGroup tag: {projectFile}."); // } // return GetProjectEntries(itemGroupNodes.SelectMany(x => x.ChildNodes.Cast<XmlNode>())); // } //} //public IEnumerable<XmlTemplateItemBase> GetProjectEntries(IEnumerable<XmlNode> nodes) //{ // var excludedNames = new List<string> { "Reference" }; // var list = nodes.Where(x => !excludedNames.Contains(x.Name)); // foreach (var node in list) // { // yield return new XmlProjectItem // { // Content = node.InnerText // }; // } //} public IProjectTemplate ReadProjectTemplate(string solutionFolder, SolutionProjectItem item, IProjectTemplate parent) { var template = new ProjectTemplate(item.IsProject); template.TemplateName = item.Name; template.Description = parent.Description; template.DefaultName = template.TemplateName; template.IconImagePath = parent.IconImagePath; template.PreviewImagePath = parent.PreviewImagePath; template.SortOrder = parent.SortOrder; template.MaxFrameworkVersion = parent.MaxFrameworkVersion; template.RequiredFrameworkVersion = parent.RequiredFrameworkVersion; template.FrameworkVersion = parent.FrameworkVersion; //if (template.IsProject) //{ // template.ProjectItems = GetProjectEntries(solutionFolder.GetFullPath(item.ProjectFileName)).ToList(); //} template.ProjectFileName = item.ProjectFileName; foreach (var itemChild in item.Children) { template.Children.Add(ReadProjectTemplate(solutionFolder, itemChild, template)); } return(template); }
private IProjectTemplate ReadProjectTemplate(string solutionFolder, SolutionProjectItem item, IProjectTemplate parent) { _logger.Debug($"{nameof(ReadProjectTemplate)} solutionFolder: {solutionFolder}"); return(_templateGenerator.ReadProjectTemplate(solutionFolder, item, parent)); }