Skip to content

Commit

Permalink
Merge pull request #4284 from WeihanLi/patch-1
Browse files Browse the repository at this point in the history
Update NuGetSourceRepositoryProvider.cs
  • Loading branch information
devlead authored Oct 3, 2024
2 parents 29611bd + a9cb965 commit 3b7ac98
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/Cake.NuGet/Client/NuGetSourceRepositoryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public NuGetSourceRepositoryProvider(ISettings settings, ICakeConfiguration conf
_localRepositories.Add(CreateRepository(SettingsUtility.GetGlobalPackagesFolder(settings)));
_localRepositories.AddRange(SettingsUtility.GetFallbackPackageFolders(settings).Select(CreateRepository));

var packageSources = new PackageSourceProvider(settings).LoadPackageSources().ToList();
var packageSources = SettingsUtility.GetEnabledSources(settings).ToList();

if (package.Address != null)
{
Expand Down Expand Up @@ -85,24 +85,20 @@ public NuGetSourceRepositoryProvider(ISettings settings, ICakeConfiguration conf
// Only add sources added via NuGet.config if nuget_source configuration value is not specified.
foreach (var source in packageSources)
{
if (source.IsEnabled)
{
var repository = CreateRepository(source);
_repositories.Add(repository);
var repository = CreateRepository(source);
_repositories.Add(repository);

// If source is not specified in directive, add it as primary source.
if (package.Address == null)
{
_primaryRepositories.Add(repository);
}
// If source is not specified in directive, add it as primary source.
if (package.Address == null)
{
_primaryRepositories.Add(repository);
}
}
}

SourceRepository GetOrCreateRepository(string source)
{
var packageSource = packageSources
.Where(p => p.IsEnabled)
.FirstOrDefault(p => p.Source.Equals(source, StringComparison.OrdinalIgnoreCase));

return packageSource == null ?
Expand Down

0 comments on commit 3b7ac98

Please sign in to comment.