@@ -265,17 +265,27 @@ private void RestoreProjects(IEnumerable<string> projects, HashSet<string>? conf
265
265
// Conservatively, we only set this to a non-null value if a Dependabot proxy is enabled.
266
266
// This ensures that we continue to get the old behaviour where feeds are taken from
267
267
// `nuget.config` files instead of the command-line arguments.
268
- HashSet < string > ? sources = null ;
268
+ string ? extraArgs = null ;
269
269
270
270
if ( this . dependabotProxy is not null )
271
271
{
272
272
// If the Dependabot proxy is configured, then our main goal is to make `dotnet` aware
273
273
// of the private registry feeds. However, since providing them as command-line arguments
274
274
// to `dotnet` ignores other feeds that may be configured, we also need to add the feeds
275
275
// we have discovered from analysing `nuget.config` files.
276
- sources = configuredSources ?? new ( ) ;
276
+ var sources = configuredSources ?? new ( ) ;
277
277
sources . Add ( PublicNugetOrgFeed ) ;
278
278
this . dependabotProxy . RegistryURLs . ForEach ( url => sources . Add ( url ) ) ;
279
+
280
+ // Add package sources. If any are present, they override all sources specified in
281
+ // the configuration file(s).
282
+ var feedArgs = new StringBuilder ( ) ;
283
+ foreach ( string source in sources )
284
+ {
285
+ feedArgs . Append ( $ " -s { source } ") ;
286
+ }
287
+
288
+ extraArgs = feedArgs . ToString ( ) ;
279
289
}
280
290
281
291
var successCount = 0 ;
@@ -292,7 +302,7 @@ private void RestoreProjects(IEnumerable<string> projects, HashSet<string>? conf
292
302
foreach ( var project in projectGroup )
293
303
{
294
304
logger . LogInfo ( $ "Restoring project { project } ...") ;
295
- var res = dotnet . Restore ( new ( project , PackageDirectory . DirInfo . FullName , ForceDotnetRefAssemblyFetching : true , sources ? . ToList ( ) , TargetWindows : isWindows ) ) ;
305
+ var res = dotnet . Restore ( new ( project , PackageDirectory . DirInfo . FullName , ForceDotnetRefAssemblyFetching : true , extraArgs , TargetWindows : isWindows ) ) ;
296
306
assets . AddDependenciesRange ( res . AssetsFilePaths ) ;
297
307
lock ( sync )
298
308
{
0 commit comments