@@ -265,17 +265,27 @@ private void RestoreProjects(IEnumerable<string> projects, HashSet<string>? conf
265265 // Conservatively, we only set this to a non-null value if a Dependabot proxy is enabled.
266266 // This ensures that we continue to get the old behaviour where feeds are taken from
267267 // `nuget.config` files instead of the command-line arguments.
268- HashSet < string > ? sources = null ;
268+ string ? extraArgs = null ;
269269
270270 if ( this . dependabotProxy is not null )
271271 {
272272 // If the Dependabot proxy is configured, then our main goal is to make `dotnet` aware
273273 // of the private registry feeds. However, since providing them as command-line arguments
274274 // to `dotnet` ignores other feeds that may be configured, we also need to add the feeds
275275 // we have discovered from analysing `nuget.config` files.
276- sources = configuredSources ?? new ( ) ;
276+ var sources = configuredSources ?? new ( ) ;
277277 sources . Add ( PublicNugetOrgFeed ) ;
278278 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 ( ) ;
279289 }
280290
281291 var successCount = 0 ;
@@ -292,7 +302,7 @@ private void RestoreProjects(IEnumerable<string> projects, HashSet<string>? conf
292302 foreach ( var project in projectGroup )
293303 {
294304 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 ) ) ;
296306 assets . AddDependenciesRange ( res . AssetsFilePaths ) ;
297307 lock ( sync )
298308 {
0 commit comments