@@ -20,6 +20,7 @@ internal sealed partial class NugetPackageRestorer : IDisposable
2020 {
2121 internal const string PublicNugetOrgFeed = "https://api.nuget.org/v3/index.json" ;
2222
23+ private readonly bool checkNugetFeedResponsiveness = EnvironmentVariables . GetBooleanOptOut ( EnvironmentVariableNames . CheckNugetFeedResponsiveness ) ;
2324 private readonly FileProvider fileProvider ;
2425 private readonly FileContent fileContent ;
2526 private readonly IDotNet dotnet ;
@@ -110,7 +111,6 @@ public DirectoryInfo[] GetOrderedPackageVersionSubDirectories(string packagePath
110111 public HashSet < AssemblyLookupLocation > Restore ( )
111112 {
112113 var assemblyLookupLocations = new HashSet < AssemblyLookupLocation > ( ) ;
113- var checkNugetFeedResponsiveness = EnvironmentVariables . GetBooleanOptOut ( EnvironmentVariableNames . CheckNugetFeedResponsiveness ) ;
114114 logger . LogInfo ( $ "Checking NuGet feed responsiveness: { checkNugetFeedResponsiveness } ") ;
115115 compilationInfoContainer . CompilationInfos . Add ( ( "NuGet feed responsiveness checked" , checkNugetFeedResponsiveness ? "1" : "0" ) ) ;
116116
@@ -130,13 +130,12 @@ public HashSet<AssemblyLookupLocation> Restore()
130130
131131 // If private package registries are configured for C#, then consider those
132132 // in addition to the ones that are configured in `nuget.config` files.
133- this . dependabotProxy ? . RegistryURLs . ForEach ( url => explicitFeeds . Add ( url ) ) ;
133+ dependabotProxy ? . RegistryURLs . ForEach ( url => explicitFeeds . Add ( url ) ) ;
134134
135- var ( explicitFeedsReachable , reachableExplicitFeeds ) =
136- this . CheckSpecifiedFeeds ( explicitFeeds ) ;
135+ var ( explicitFeedsReachable , reachableExplicitFeeds ) = CheckSpecifiedFeeds ( explicitFeeds ) ;
137136 reachableFeeds . UnionWith ( reachableExplicitFeeds ) ;
138137
139- reachableFeeds . UnionWith ( this . GetReachableNuGetFeeds ( inheritedFeeds , isFallback : false ) ) ;
138+ reachableFeeds . UnionWith ( GetReachableNuGetFeeds ( inheritedFeeds , isFallback : false ) ) ;
140139
141140 if ( inheritedFeeds . Count > 0 )
142141 {
@@ -193,6 +192,7 @@ public HashSet<AssemblyLookupLocation> Restore()
193192 }
194193
195194 // Restore project dependencies with `dotnet restore`.
195+ // TODO: We also need to respect reachable feeds for resolution restore.
196196 var restoredProjects = RestoreSolutions ( out var container ) ;
197197 var projects = fileProvider . Projects . Except ( restoredProjects ) ;
198198 RestoreProjects ( projects , reachableFeeds , out var containers ) ;
@@ -320,14 +320,14 @@ private void RestoreProjects(IEnumerable<string> projects, HashSet<string>? conf
320320 // `nuget.config` files instead of the command-line arguments.
321321 string ? extraArgs = null ;
322322
323- if ( this . dependabotProxy is not null )
323+ if ( dependabotProxy is not null )
324324 {
325325 // If the Dependabot proxy is configured, then our main goal is to make `dotnet` aware
326326 // of the private registry feeds. However, since providing them as command-line arguments
327327 // to `dotnet` ignores other feeds that may be configured, we also need to add the feeds
328328 // we have discovered from analysing `nuget.config` files.
329329 var sources = configuredSources ?? new ( ) ;
330- this . dependabotProxy . RegistryURLs . ForEach ( url => sources . Add ( url ) ) ;
330+ dependabotProxy . RegistryURLs . ForEach ( url => sources . Add ( url ) ) ;
331331
332332 // Add package sources. If any are present, they override all sources specified in
333333 // the configuration file(s).
@@ -680,11 +680,11 @@ private bool IsFeedReachable(string feed, int timeoutMilliSeconds, int tryCount,
680680
681681 // Configure the HttpClient to be aware of the Dependabot Proxy, if used.
682682 HttpClientHandler httpClientHandler = new ( ) ;
683- if ( this . dependabotProxy != null )
683+ if ( dependabotProxy != null )
684684 {
685- httpClientHandler . Proxy = new WebProxy ( this . dependabotProxy . Address ) ;
685+ httpClientHandler . Proxy = new WebProxy ( dependabotProxy . Address ) ;
686686
687- if ( this . dependabotProxy . Certificate != null )
687+ if ( dependabotProxy . Certificate != null )
688688 {
689689 httpClientHandler . ServerCertificateCustomValidationCallback = ( message , cert , chain , _ ) =>
690690 {
@@ -699,7 +699,7 @@ private bool IsFeedReachable(string feed, int timeoutMilliSeconds, int tryCount,
699699 return false ;
700700 }
701701 chain . ChainPolicy . TrustMode = X509ChainTrustMode . CustomRootTrust ;
702- chain . ChainPolicy . CustomTrustStore . Add ( this . dependabotProxy . Certificate ) ;
702+ chain . ChainPolicy . CustomTrustStore . Add ( dependabotProxy . Certificate ) ;
703703 return chain . Build ( cert ) ;
704704 } ;
705705 }
@@ -788,10 +788,10 @@ private HashSet<string> GetExcludedFeeds()
788788 var excludedFeeds = GetExcludedFeeds ( ) ;
789789
790790 var feedsToCheck = feeds . Where ( feed => ! excludedFeeds . Contains ( feed ) ) . ToHashSet ( ) ;
791- var reachableFeeds = this . GetReachableNuGetFeeds ( feedsToCheck , isFallback : false ) ;
791+ var reachableFeeds = GetReachableNuGetFeeds ( feedsToCheck , isFallback : false ) ;
792792 var allFeedsReachable = reachableFeeds . Count == feedsToCheck . Count ;
793793
794- this . EmitUnreachableFeedsDiagnostics ( allFeedsReachable ) ;
794+ EmitUnreachableFeedsDiagnostics ( allFeedsReachable ) ;
795795
796796 return ( allFeedsReachable , reachableFeeds ) ;
797797 }
@@ -863,11 +863,11 @@ private IEnumerable<string> GetFeeds(Func<IList<string>> getNugetFeeds)
863863
864864 if ( invalidNugetConfigs . Count ( ) > 0 )
865865 {
866- this . logger . LogWarning ( string . Format (
866+ logger . LogWarning ( string . Format (
867867 "Found incorrectly named NuGet configuration files: {0}" ,
868868 string . Join ( ", " , invalidNugetConfigs )
869869 ) ) ;
870- this . diagnosticsWriter . AddEntry ( new DiagnosticMessage (
870+ diagnosticsWriter . AddEntry ( new DiagnosticMessage (
871871 Language . CSharp ,
872872 "buildless/case-sensitive-nuget-config" ,
873873 "Found NuGet configuration files which are not correctly named" ,
@@ -933,7 +933,7 @@ private IEnumerable<string> GetFeeds(Func<IList<string>> getNugetFeeds)
933933 else
934934 {
935935 // If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory.
936- allFeeds = GetFeeds ( ( ) => dotnet . GetNugetFeedsFromFolder ( this . fileProvider . SourceDir . FullName ) ) . ToHashSet ( ) ;
936+ allFeeds = GetFeeds ( ( ) => dotnet . GetNugetFeedsFromFolder ( fileProvider . SourceDir . FullName ) ) . ToHashSet ( ) ;
937937 }
938938
939939 logger . LogInfo ( $ "Found { allFeeds . Count } NuGet feeds (with inherited ones) in nuget.config files: { string . Join ( ", " , allFeeds . OrderBy ( f => f ) ) } ") ;
0 commit comments