Skip to content

Commit 76fe3fa

Browse files
committed
C#: Make sure allFeeds contains at least explicitFeeds
1 parent 34800d1 commit 76fe3fa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,17 @@ private IEnumerable<string> GetFeeds(Func<IList<string>> getNugetFeeds)
856856
allFeeds = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet();
857857
}
858858

859+
// If we have discovered any explicit feeds, then we also expect these to be in the set of all feeds.
860+
// Normally, it is a safe assumption to make that `GetNugetFeedsFromFolder` will include the feeds configured
861+
// in a NuGet configuration file in the given directory. There is one exception: on a system with case-sensitive
862+
// file systems, we may discover a configuration file such as `Nuget.Config` which is not recognised by `dotnet nuget`.
863+
// In that case, our call to `GetNugetFeeds` will retrieve the feeds from that file (because it is accepted when
864+
// provided explicitly as `--configfile` argument), but the call to `GetNugetFeedsFromFolder` will not.
865+
if (explicitFeeds.Count > 0)
866+
{
867+
allFeeds.UnionWith(explicitFeeds);
868+
}
869+
859870
logger.LogInfo($"Found {allFeeds.Count} NuGet feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}");
860871

861872
return (explicitFeeds, allFeeds);

0 commit comments

Comments
 (0)