Skip to content

Commit a8d9beb

Browse files
authored
fix(tools): enumerate projects recursively through solution folders (#48)
1 parent 64ccb55 commit a8d9beb

1 file changed

Lines changed: 30 additions & 7 deletions

File tree

src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,32 @@ public async Task<List<ProjectInfo>> GetProjectsAsync()
106106

107107
foreach (EnvDTE.Project project in dte.Solution.Projects)
108108
{
109-
try
109+
CollectProjects(project, projects);
110+
}
111+
112+
return projects;
113+
}
114+
115+
private static void CollectProjects(EnvDTE.Project project, List<ProjectInfo> projects)
116+
{
117+
ThreadHelper.ThrowIfNotOnUIThread();
118+
119+
try
120+
{
121+
if (project.Kind == ProjectKinds.vsProjectKindSolutionFolder)
122+
{
123+
if (project.ProjectItems != null)
124+
{
125+
foreach (ProjectItem item in project.ProjectItems)
126+
{
127+
if (item.SubProject != null)
128+
{
129+
CollectProjects(item.SubProject, projects);
130+
}
131+
}
132+
}
133+
}
134+
else
110135
{
111136
projects.Add(new ProjectInfo
112137
{
@@ -115,13 +140,11 @@ public async Task<List<ProjectInfo>> GetProjectsAsync()
115140
Kind = project.Kind
116141
});
117142
}
118-
catch (Exception ex)
119-
{
120-
VsixTelemetry.TrackException(ex);
121-
}
122143
}
123-
124-
return projects;
144+
catch (Exception ex)
145+
{
146+
VsixTelemetry.TrackException(ex);
147+
}
125148
}
126149

127150
public async Task<List<DocumentInfo>> GetOpenDocumentsAsync()

0 commit comments

Comments
 (0)