martinecker / rudebuild

A non-intrusive bulk/unity C++ build tool for Visual Studio
Other
16 stars 6 forks source link

solution settings don't support solution folders #12

Closed Trass3r closed 8 years ago

Trass3r commented 8 years ago

http://www.wwwlicious.com/2011/03/29/envdte-getting-all-projects-html/

tested quick hack:

index 2500dd9..277b3a2 100644
--- a/src/RudeBuildVSShared/SolutionSettingsDialog.xaml.cs
+++ b/src/RudeBuildVSShared/SolutionSettingsDialog.xaml.cs
@@ -1,15 +1,43 @@
 using System;
 using System.Collections.Generic;
+using System.IO.Packaging;
+using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls.Primitives;
 using System.Windows.Media.Imaging;
 using System.Runtime.InteropServices;
+using EnvDTE;
+using EnvDTE80;
 using Microsoft.VisualStudio.Shell.Interop;
 using RudeBuild;
+using Window = System.Windows.Window;

 namespace RudeBuildVSShared
 {
+   public static class SolutionProjects
+   {
+       public static IEnumerable<Project> GetAllProjects(this Solution sln)
+       {
+           return sln.Projects
+               .Cast<Project>()
+               .SelectMany(GetProjects);
+       }
+
+       private static IEnumerable<Project> GetProjects(Project project)
+       {
+           if (project.Kind == ProjectKinds.vsProjectKindSolutionFolder)
+           {
+               return project.ProjectItems
+                   .Cast<ProjectItem>()
+                   .Select(x => x.SubProject)
+                   .Where(x => x != null)
+                   .SelectMany(GetProjects);
+           }
+           return new[] { project };
+       }
+   }
+
     public class SolutionHierarchy
     {
         public class Item
@@ -295,7 +323,7 @@ namespace RudeBuildVSShared
         {
             var solutionService = commandManager.GetService<IVsSolution>(typeof(SVsSolution));

-            foreach (EnvDTE.Project project in commandManager.Application.Solution.Projects)
+            foreach (Project project in commandManager.Application.Solution.GetAllProjects())
             {
                 var projectInfo = _solutionInfo.GetProjectInfo(project.Name);
                 if (null != projectInfo)
martinecker commented 8 years ago

Full fix submitted, see here: https://github.com/martinecker/rudebuild/commit/cfefc2b7a861a82955e9781d23eb3f606eed316e Thanks for the bug report.

Trass3r commented 8 years ago

Thanks. btw would be nice if the saved RudeBuild.config file only contained those project entries with actual file exclusions.