Skip to content

Commit 0a7ad13

Browse files
author
Stephan
committed
Improve handling of VS projects
1 parent 4e2d96c commit 0a7ad13

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Zbu.ModelsBuilder.CustomTool/VisualStudio/VisualStudioHelper.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,27 @@ public static EnvDTE.ProjectItem GetSourceItem(string inputFilePath)
4949
// process the project
5050
.Cast<EnvDTE.Project>()
5151
// exclude project types that are know to cause ToHierarchy to throw
52-
.Where(p => !ExcludedProjectKinds.Contains(p.Kind.ToLowerInvariant()))
52+
.Where(p =>
53+
{
54+
var exclude = ExcludedProjectKinds.Contains(p.Kind.ToLowerInvariant());
55+
if (!exclude) return true;
56+
57+
var msg = string.Format("Skipping project \"{0}\" at \"{1}\" of kind \"{2}\" (excluded kind).",
58+
p.FullName, p.FileName, p.Kind);
59+
ReportMessage(msg);
60+
return false;
61+
})
62+
// exclude projet types that don't have a filename (ToHierarchy cannot work)
63+
.Where(p =>
64+
{
65+
var exclude = string.IsNullOrWhiteSpace(p.FileName);
66+
if (!exclude) return true;
67+
68+
var msg = string.Format("Skipping project \"{0}\" at \"{1}\" of kind \"{2}\" (empty filename).",
69+
p.FullName, p.FileName, p.Kind);
70+
ReportMessage(msg);
71+
return false;
72+
})
5373
// try...catch ToHierarchy, in case it's a project type we should have excluded
5474
.Select(x =>
5575
{
@@ -64,7 +84,7 @@ public static EnvDTE.ProjectItem GetSourceItem(string inputFilePath)
6484

6585
// what shall we do? throwing is not nice neither required, but it's the
6686
// only way we can add project kinds to our exclude list... for the time
67-
// being, throw.
87+
// being, be a pain to everybody and throw
6888
throw new Exception(errmsg, e);
6989
//ReportMessage(errmsg);
7090
//return null;

0 commit comments

Comments
 (0)