@@ -36,6 +36,7 @@ public sealed partial class DependencyManager : IDisposable
36
36
private readonly TemporaryDirectory legacyPackageDirectory ;
37
37
private readonly TemporaryDirectory missingPackageDirectory ;
38
38
private readonly TemporaryDirectory tempWorkingDirectory ;
39
+ private readonly FileProvider fileProvider ;
39
40
private readonly bool cleanupTempWorkingDirectory ;
40
41
41
42
private readonly Lazy < Runtime > runtimeLazy ;
@@ -79,20 +80,10 @@ public DependencyManager(string srcDir, ILogger logger)
79
80
80
81
tempWorkingDirectory = new TemporaryDirectory ( FileUtils . GetTemporaryWorkingDirectory ( out cleanupTempWorkingDirectory ) ) ;
81
82
82
- logger . LogInfo ( $ "Finding files in { srcDir } ...") ;
83
-
84
- var allFiles = GetAllFiles ( ) . ToList ( ) ;
85
- var binaryFileExtensions = new HashSet < string > ( new [ ] { ".dll" , ".exe" } ) ; // TODO: add more binary file extensions.
86
- var allNonBinaryFiles = allFiles . Where ( f => ! binaryFileExtensions . Contains ( f . Extension . ToLowerInvariant ( ) ) ) . ToList ( ) ;
87
- var smallNonBinaryFiles = allNonBinaryFiles . SelectSmallFiles ( logger ) . SelectFileNames ( ) . ToList ( ) ;
88
- this . fileContent = new FileContent ( logger , smallNonBinaryFiles ) ;
89
- this . nonGeneratedSources = allNonBinaryFiles . SelectFileNamesByExtension ( ".cs" ) . ToList ( ) ;
90
- this . generatedSources = new ( ) ;
91
- var allProjects = allNonBinaryFiles . SelectFileNamesByExtension ( ".csproj" ) . ToList ( ) ;
92
- var allSolutions = allNonBinaryFiles . SelectFileNamesByExtension ( ".sln" ) . ToList ( ) ;
93
- var dllLocations = allFiles . SelectFileNamesByExtension ( ".dll" ) . Select ( x => new AssemblyLookupLocation ( x ) ) . ToHashSet ( ) ;
94
-
95
- logger . LogInfo ( $ "Found { allFiles . Count } files, { nonGeneratedSources . Count } source files, { allProjects . Count } project files, { allSolutions . Count } solution files, { dllLocations . Count } DLLs.") ;
83
+ this . fileProvider = new FileProvider ( sourceDir , logger ) ;
84
+ this . fileContent = new FileContent ( logger , this . fileProvider . SmallNonBinary ) ;
85
+ this . nonGeneratedSources = fileProvider . Sources . ToList ( ) ;
86
+ this . generatedSources = [ ] ;
96
87
97
88
void startCallback ( string s , bool silent )
98
89
{
@@ -104,7 +95,7 @@ void exitCallback(int ret, string msg, bool silent)
104
95
logger . Log ( silent ? Severity . Debug : Severity . Info , $ "Exit code { ret } { ( string . IsNullOrEmpty ( msg ) ? "" : $ ": { msg } ") } ") ;
105
96
}
106
97
107
- DotNet . WithDotNet ( SystemBuildActions . Instance , logger , smallNonBinaryFiles , tempWorkingDirectory . ToString ( ) , shouldCleanUp : false , ensureDotNetAvailable : true , version : null , installDir =>
98
+ DotNet . WithDotNet ( SystemBuildActions . Instance , logger , fileProvider . GlobalJsons , tempWorkingDirectory . ToString ( ) , shouldCleanUp : false , ensureDotNetAvailable : true , version : null , installDir =>
108
99
{
109
100
this . dotnetPath = installDir ;
110
101
return BuildScript . Success ;
@@ -121,13 +112,14 @@ void exitCallback(int ret, string msg, bool silent)
121
112
throw ;
122
113
}
123
114
124
- RestoreNugetPackages ( allNonBinaryFiles , allProjects , allSolutions , dllLocations ) ;
115
+ var dllLocations = fileProvider . Dlls . Select ( x => new AssemblyLookupLocation ( x ) ) . ToHashSet ( ) ;
116
+ RestoreNugetPackages ( dllLocations ) ;
125
117
// Find DLLs in the .Net / Asp.Net Framework
126
118
// This needs to come after the nuget restore, because the nuget restore might fetch the .NET Core/Framework reference assemblies.
127
119
var frameworkLocations = AddFrameworkDlls ( dllLocations ) ;
128
120
129
121
assemblyCache = new AssemblyCache ( dllLocations , frameworkLocations , logger ) ;
130
- AnalyseSolutions ( allSolutions ) ;
122
+ AnalyseSolutions ( fileProvider . Solutions ) ;
131
123
132
124
foreach ( var filename in assemblyCache . AllAssemblies . Select ( a => a . Filename ) )
133
125
{
@@ -154,7 +146,7 @@ void exitCallback(int ret, string msg, bool silent)
154
146
shouldExtractWebViews )
155
147
{
156
148
CompilationInfos . Add ( ( "WebView extraction enabled" , "1" ) ) ;
157
- GenerateSourceFilesFromWebViews ( allNonBinaryFiles ) ;
149
+ GenerateSourceFilesFromWebViews ( ) ;
158
150
}
159
151
else
160
152
{
@@ -171,8 +163,8 @@ void exitCallback(int ret, string msg, bool silent)
171
163
logger . LogInfo ( "Build analysis summary:" ) ;
172
164
logger . LogInfo ( $ "{ nonGeneratedSources . Count , align } source files found on the filesystem") ;
173
165
logger . LogInfo ( $ "{ generatedSources . Count , align } source files have been generated") ;
174
- logger . LogInfo ( $ "{ allSolutions . Count , align } solution files found on the filesystem") ;
175
- logger . LogInfo ( $ "{ allProjects . Count , align } project files found on the filesystem") ;
166
+ logger . LogInfo ( $ "{ fileProvider . Solutions . Count , align } solution files found on the filesystem") ;
167
+ logger . LogInfo ( $ "{ fileProvider . Projects . Count , align } project files found on the filesystem") ;
176
168
logger . LogInfo ( $ "{ usedReferences . Keys . Count , align } resolved references") ;
177
169
logger . LogInfo ( $ "{ unresolvedReferences . Count , align } unresolved references") ;
178
170
logger . LogInfo ( $ "{ conflictedReferences , align } resolved assembly conflicts") ;
@@ -182,8 +174,8 @@ void exitCallback(int ret, string msg, bool silent)
182
174
CompilationInfos . AddRange ( [
183
175
( "Source files on filesystem" , nonGeneratedSources . Count . ToString ( ) ) ,
184
176
( "Source files generated" , generatedSources . Count . ToString ( ) ) ,
185
- ( "Solution files on filesystem" , allSolutions . Count . ToString ( ) ) ,
186
- ( "Project files on filesystem" , allProjects . Count . ToString ( ) ) ,
177
+ ( "Solution files on filesystem" , fileProvider . Solutions . Count . ToString ( ) ) ,
178
+ ( "Project files on filesystem" , fileProvider . Projects . Count . ToString ( ) ) ,
187
179
( "Resolved references" , usedReferences . Keys . Count . ToString ( ) ) ,
188
180
( "Unresolved references" , unresolvedReferences . Count . ToString ( ) ) ,
189
181
( "Resolved assembly conflicts" , conflictedReferences . ToString ( ) ) ,
@@ -467,15 +459,15 @@ private void GenerateSourceFileFromImplicitUsings()
467
459
}
468
460
}
469
461
470
- private void GenerateSourceFilesFromWebViews ( List < FileInfo > allFiles )
462
+ private void GenerateSourceFilesFromWebViews ( )
471
463
{
472
- var views = allFiles . SelectFileNamesByExtension ( ".cshtml" , ".razor" ) . ToArray ( ) ;
473
- if ( views . Length == 0 )
464
+ var views = fileProvider . RazorViews ;
465
+ if ( views . Count == 0 )
474
466
{
475
467
return ;
476
468
}
477
469
478
- logger . LogInfo ( $ "Found { views . Length } cshtml and razor files.") ;
470
+ logger . LogInfo ( $ "Found { views . Count } cshtml and razor files.") ;
479
471
480
472
if ( ! IsAspNetCoreDetected ( ) )
481
473
{
@@ -503,38 +495,6 @@ private void GenerateSourceFilesFromWebViews(List<FileInfo> allFiles)
503
495
}
504
496
}
505
497
506
- private IEnumerable < FileInfo > GetAllFiles ( )
507
- {
508
- IEnumerable < FileInfo > files = sourceDir . GetFiles ( "*.*" , new EnumerationOptions { RecurseSubdirectories = true } ) ;
509
-
510
- if ( dotnetPath != null )
511
- {
512
- files = files . Where ( f => ! f . FullName . StartsWith ( dotnetPath , StringComparison . OrdinalIgnoreCase ) ) ;
513
- }
514
-
515
- files = files . Where ( f =>
516
- {
517
- try
518
- {
519
- if ( f . Exists )
520
- {
521
- return true ;
522
- }
523
-
524
- logger . LogWarning ( $ "File { f . FullName } could not be processed.") ;
525
- return false ;
526
- }
527
- catch ( Exception ex )
528
- {
529
- logger . LogWarning ( $ "File { f . FullName } could not be processed: { ex . Message } ") ;
530
- return false ;
531
- }
532
- } ) ;
533
-
534
- files = new FilePathFilter ( sourceDir , logger ) . Filter ( files ) ;
535
- return files ;
536
- }
537
-
538
498
/// <summary>
539
499
/// Computes a unique temp directory for the packages associated
540
500
/// with this source tree. Use a SHA1 of the directory name.
0 commit comments