@@ -23,13 +23,13 @@ public class Project : ProjectOrSolution
2323
2424 public Version ToolsVersion { get ; private set ; }
2525
26- readonly List < Project > includedProjects = new List < Project > ( ) ;
27- public override IEnumerable < IProjectOrSolution > IncludedProjects =>
28- includedProjects . Concat ( includedProjects . SelectMany ( s => s . IncludedProjects ) ) ;
26+ readonly Lazy < List < Project > > includedProjectsLazy ;
27+ public override IEnumerable < IProjectOrSolution > IncludedProjects => includedProjectsLazy . Value ;
2928
3029 public Project ( Autobuilder builder , string path ) : base ( builder , path )
3130 {
3231 ToolsVersion = new Version ( ) ;
32+ includedProjectsLazy = new Lazy < List < Project > > ( ( ) => new List < Project > ( ) ) ;
3333
3434 if ( ! builder . Actions . FileExists ( FullPath ) )
3535 return ;
@@ -69,17 +69,22 @@ public Project(Autobuilder builder, string path) : base(builder, path)
6969 }
7070 }
7171
72- // The documentation on `.proj` files is very limited, but it appears that both
73- // `<ProjectFile Include="X"/>` and `<ProjectFiles Include="X"/>` is valid
74- var mgr = new XmlNamespaceManager ( projFile . NameTable ) ;
75- mgr . AddNamespace ( "msbuild" , "http://schemas.microsoft.com/developer/msbuild/2003" ) ;
76- var projectFileIncludes = root . SelectNodes ( "//msbuild:Project/msbuild:ItemGroup/msbuild:ProjectFile/@Include" , mgr ) . OfType < XmlNode > ( ) ;
77- var projectFilesIncludes = root . SelectNodes ( "//msbuild:Project/msbuild:ItemGroup/msbuild:ProjectFiles/@Include" , mgr ) . OfType < XmlNode > ( ) ;
78- foreach ( var include in projectFileIncludes . Concat ( projectFilesIncludes ) )
72+ includedProjectsLazy = new Lazy < List < Project > > ( ( ) =>
7973 {
80- var includePath = builder . Actions . IsWindows ( ) ? include . Value : include . Value . Replace ( "\\ " , "/" ) ;
81- includedProjects . Add ( new Project ( builder , builder . Actions . PathCombine ( Path . GetDirectoryName ( this . FullPath ) , includePath ) ) ) ;
82- }
74+ var ret = new List < Project > ( ) ;
75+ // The documentation on `.proj` files is very limited, but it appears that both
76+ // `<ProjectFile Include="X"/>` and `<ProjectFiles Include="X"/>` is valid
77+ var mgr = new XmlNamespaceManager ( projFile . NameTable ) ;
78+ mgr . AddNamespace ( "msbuild" , "http://schemas.microsoft.com/developer/msbuild/2003" ) ;
79+ var projectFileIncludes = root . SelectNodes ( "//msbuild:Project/msbuild:ItemGroup/msbuild:ProjectFile/@Include" , mgr ) . OfType < XmlNode > ( ) ;
80+ var projectFilesIncludes = root . SelectNodes ( "//msbuild:Project/msbuild:ItemGroup/msbuild:ProjectFiles/@Include" , mgr ) . OfType < XmlNode > ( ) ;
81+ foreach ( var include in projectFileIncludes . Concat ( projectFilesIncludes ) )
82+ {
83+ var includePath = builder . Actions . IsWindows ( ) ? include . Value : include . Value . Replace ( "\\ " , "/" ) ;
84+ ret . Add ( new Project ( builder , builder . Actions . PathCombine ( Path . GetDirectoryName ( this . FullPath ) , includePath ) ) ) ;
85+ }
86+ return ret ;
87+ } ) ;
8388 }
8489 }
8590 }
0 commit comments