@@ -133,9 +133,9 @@ public BuildAnalysis(Options options, ProgressMonitor progressMonitor)
133133 DateTime . Now - startTime ) ;
134134 }
135135
136- private IEnumerable < string > GetFiles ( string pattern )
136+ private IEnumerable < string > GetFiles ( string pattern , bool recurseSubdirectories = true )
137137 {
138- return sourceDir . GetFiles ( pattern , SearchOption . AllDirectories )
138+ return sourceDir . GetFiles ( pattern , new EnumerationOptions { RecurseSubdirectories = recurseSubdirectories , MatchCasing = MatchCasing . CaseInsensitive } )
139139 . Select ( d => d . FullName )
140140 . Where ( d => ! options . ExcludesFile ( d ) ) ;
141141 }
@@ -318,16 +318,16 @@ private void AnalyseProject(FileInfo project)
318318
319319 }
320320
321- private bool Restore ( string target )
321+ private bool Restore ( string target , string ? pathToNugetConfig = null )
322322 {
323- return dotnet . RestoreToDirectory ( target , packageDirectory . DirInfo . FullName ) ;
323+ return dotnet . RestoreToDirectory ( target , packageDirectory . DirInfo . FullName , pathToNugetConfig ) ;
324324 }
325325
326- private void Restore ( IEnumerable < string > targets )
326+ private void Restore ( IEnumerable < string > targets , string ? pathToNugetConfig = null )
327327 {
328328 foreach ( var target in targets )
329329 {
330- Restore ( target ) ;
330+ Restore ( target , pathToNugetConfig ) ;
331331 }
332332 }
333333
@@ -336,7 +336,23 @@ private void DownloadMissingPackages(IEnumerable<string> restoreTargets)
336336 var alreadyDownloadedPackages = Directory . GetDirectories ( packageDirectory . DirInfo . FullName ) . Select ( d => Path . GetFileName ( d ) . ToLowerInvariant ( ) ) . ToHashSet ( ) ;
337337 var notYetDownloadedPackages = new HashSet < string > ( ) ;
338338
339- var allFiles = GetFiles ( "*.*" ) . ToArray ( ) ;
339+ var nugetConfigs = GetFiles ( "nuget.config" , recurseSubdirectories : true ) . ToArray ( ) ;
340+ string ? nugetConfig = null ;
341+ if ( nugetConfigs . Length > 1 )
342+ {
343+ progressMonitor . MultipleNugetConfig ( nugetConfigs ) ;
344+ nugetConfig = GetFiles ( "nuget.config" , recurseSubdirectories : false ) . FirstOrDefault ( ) ;
345+ if ( nugetConfig == null )
346+ {
347+ progressMonitor . NoTopLevelNugetConfig ( ) ;
348+ }
349+ }
350+ else
351+ {
352+ nugetConfig = nugetConfigs . FirstOrDefault ( ) ;
353+ }
354+
355+ var allFiles = GetFiles ( "*.*" ) ;
340356 foreach ( var file in allFiles )
341357 {
342358 try
@@ -390,7 +406,7 @@ private void DownloadMissingPackages(IEnumerable<string> restoreTargets)
390406 continue ;
391407 }
392408
393- success = Restore ( tempDir . DirInfo . FullName ) ;
409+ success = Restore ( tempDir . DirInfo . FullName , nugetConfig ) ;
394410
395411 // TODO: the restore might fail, we could retry with a prerelease (*-* instead of *) version of the package.
396412
0 commit comments