public static ProjectItem GetOrCreateFolder(this DTE2 dte, string folderName) { ProjectItems projectItems = dte.GetSelectedProjectItems(); if (projectItems.ContainingProject.TryFindProjectItemByName(folderName, out ProjectItem foundItem)) { return(foundItem); } return(projectItems.AddFolder(folderName)); }