Skip to content

Commit

Permalink
Fixes #81: Unloaded projects lead to failures when trying to check th…
Browse files Browse the repository at this point in the history
…e path. If an error occurs while reading the projects for a solution we now log the error, but add the other projects.
  • Loading branch information
StefanKert committed Jul 17, 2020
1 parent 1b9d837 commit 5063f67
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/BuildVision/Helpers/SolutionProjectsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,29 @@ public static IList<Project> GetProjects(this Solution solution)
var list = new List<Project>();
foreach (var proj in solution.Projects)
{
var project = proj as Project;
if (project == null)
if (!(proj is Project project))
{
continue;
}

if (project.FileName.EndsWith(".shproj")) // Shared Projects shouldn´t be displayed in BuildVision
try
{
continue;
}
if (project.FileName.EndsWith(".shproj")) // Shared Projects shouldn´t be displayed in BuildVision
{
continue;
}

if (project.Kind == EnvDTEProjectKinds.ProjectKindSolutionFolder)
{
list.AddRange(project.GetSubProjects());
if (project.Kind == EnvDTEProjectKinds.ProjectKindSolutionFolder)
{
list.AddRange(project.GetSubProjects());
}
else if (!project.IsHidden())
{
list.Add(project);
}
}
else if (!project.IsHidden())
catch (Exception ex)
{
list.Add(project);
LogManager.ForContext<Solution>().Error(ex, "Failed to load project with name {UniqueName} for solution {FullName}", project.UniqueName, solution?.FullName);
}
}
return list;
Expand Down

0 comments on commit 5063f67

Please sign in to comment.