@@ -133,9 +133,9 @@ public BuildAnalysis(Options options, ProgressMonitor progressMonitor)
133
133
DateTime . Now - startTime ) ;
134
134
}
135
135
136
- private IEnumerable < string > GetFiles ( string pattern )
136
+ private IEnumerable < string > GetFiles ( string pattern , bool recurseSubdirectories = true )
137
137
{
138
- return sourceDir . GetFiles ( pattern , SearchOption . AllDirectories )
138
+ return sourceDir . GetFiles ( pattern , new EnumerationOptions { RecurseSubdirectories = recurseSubdirectories , MatchCasing = MatchCasing . CaseInsensitive } )
139
139
. Select ( d => d . FullName )
140
140
. Where ( d => ! options . ExcludesFile ( d ) ) ;
141
141
}
@@ -318,16 +318,16 @@ private void AnalyseProject(FileInfo project)
318
318
319
319
}
320
320
321
- private bool Restore ( string target )
321
+ private bool Restore ( string target , string ? pathToNugetConfig = null )
322
322
{
323
- return dotnet . RestoreToDirectory ( target , packageDirectory . DirInfo . FullName ) ;
323
+ return dotnet . RestoreToDirectory ( target , packageDirectory . DirInfo . FullName , pathToNugetConfig ) ;
324
324
}
325
325
326
- private void Restore ( IEnumerable < string > targets )
326
+ private void Restore ( IEnumerable < string > targets , string ? pathToNugetConfig = null )
327
327
{
328
328
foreach ( var target in targets )
329
329
{
330
- Restore ( target ) ;
330
+ Restore ( target , pathToNugetConfig ) ;
331
331
}
332
332
}
333
333
@@ -336,7 +336,23 @@ private void DownloadMissingPackages(IEnumerable<string> restoreTargets)
336
336
var alreadyDownloadedPackages = Directory . GetDirectories ( packageDirectory . DirInfo . FullName ) . Select ( d => Path . GetFileName ( d ) . ToLowerInvariant ( ) ) . ToHashSet ( ) ;
337
337
var notYetDownloadedPackages = new HashSet < string > ( ) ;
338
338
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 ( "*.*" ) ;
340
356
foreach ( var file in allFiles )
341
357
{
342
358
try
@@ -390,7 +406,7 @@ private void DownloadMissingPackages(IEnumerable<string> restoreTargets)
390
406
continue ;
391
407
}
392
408
393
- success = Restore ( tempDir . DirInfo . FullName ) ;
409
+ success = Restore ( tempDir . DirInfo . FullName , nugetConfig ) ;
394
410
395
411
// TODO: the restore might fail, we could retry with a prerelease (*-* instead of *) version of the package.
396
412
0 commit comments