I have a project template and whenever I try to add an item template, it's created in the right place (folder) but also adds the item in the first folder added to the project. How can i fix this?
Code:
if (project.Kind == PrjKind.prjKindCSharpProject) {
itemPath = solution.GetProjectItemTemplate("PriClass.zip", "CSharp");
fileExtension = ".cs";
} else {
itemPath = solution.GetProjectItemTemplate("PriClass.zip", "VisualBasic");
fileExtension = ".vb";
}
if (!String.IsNullOrEmpty(itemPath)) {
foreach(MyTreeNode type in selectedTypes) {
string[] namespaceParts = type.Namespace.Split('.');
if (namespaceParts.Length == 4) {
this.Module = namespaceParts[2];
this.ModuleType = namespaceParts[3];
this.ClassName = type.NodeName;
ProjectItem rootFolder = project.ProjectItems.Cast < ProjectItem > ()
.FirstOrDefault(i => i.Name == this.Module) ? ? project.ProjectItems.AddFolder(this.Module);
switch (this.ModuleType) {
case "Editors":
rootFolder.ProjectItems.AddFromTemplate(itemPath, "Ui" + this.ClassName + fileExtension);
break;
case "Services":
rootFolder.ProjectItems.AddFromTemplate(itemPath, "Api" + this.ClassName + fileExtension);
break;
}
}
}
Project after created:
Try removing the "Template Data" content that is located in your case from the "PriClass.zip" folder. This should be enough so that the "PriClass" folder does not come to seem like when you add an Item / Class.
Example: