From 24377183c7ac380fe9ec6fb96d2d527a972fd569 Mon Sep 17 00:00:00 2001 From: "Calvin A. Allen" Date: Tue, 24 Mar 2026 10:50:36 -0400 Subject: [PATCH] fix(tools): enumerate projects recursively through solution folders --- .../Services/VisualStudioService.cs | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs b/src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs index 5efd6ca..e575dd6 100644 --- a/src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs +++ b/src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs @@ -106,7 +106,32 @@ public async Task> GetProjectsAsync() foreach (EnvDTE.Project project in dte.Solution.Projects) { - try + CollectProjects(project, projects); + } + + return projects; + } + + private static void CollectProjects(EnvDTE.Project project, List projects) + { + ThreadHelper.ThrowIfNotOnUIThread(); + + try + { + if (project.Kind == ProjectKinds.vsProjectKindSolutionFolder) + { + if (project.ProjectItems != null) + { + foreach (ProjectItem item in project.ProjectItems) + { + if (item.SubProject != null) + { + CollectProjects(item.SubProject, projects); + } + } + } + } + else { projects.Add(new ProjectInfo { @@ -115,13 +140,11 @@ public async Task> GetProjectsAsync() Kind = project.Kind }); } - catch (Exception ex) - { - VsixTelemetry.TrackException(ex); - } } - - return projects; + catch (Exception ex) + { + VsixTelemetry.TrackException(ex); + } } public async Task> GetOpenDocumentsAsync()