Skip to content

C#: Improve BMN feed checking & handling. - #21684

Merged
michaelnebel merged 33 commits into
github:mainfrom
michaelnebel:csharp/improve-reachability-checks
Apr 30, 2026
Merged

C#: Improve BMN feed checking & handling.#21684
michaelnebel merged 33 commits into
github:mainfrom
michaelnebel:csharp/improve-reachability-checks

Conversation

@michaelnebel

@michaelnebel michaelnebel commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

In this PR we make some improvements to the C# NuGet feed check and use of private registries.

The primary change(s) in this PR

  • Explicitly provide a list of NuGet sources for dotnet restore (both for projects and solutions) which overrides the use of nuget.config files (unless NuGet feed reachability check is disabled and no private registries are configured). For both explicit and implicit feeds, we only use the feeds that we can successfully connect to (there is still an envionment variable that makes it possible to override the feed check for a list of feeds - and then they will be included no matter what). However, this is still a significant change in the semantics of the dependency resolution. Previously, we used all feeds and let dotnet restore sort out issues with the feeds. However, it turns out that it might cause a significant slowdown to the restore process, if we use feeds that eg. issues 401/403 responses.
  • The list NuGet sources is based on nuget.config files in the repository (including environment specific nuget configuration). The list is created per project/solution to correctly as possible reflect the sources intended for use by a specific project/solution.
  • In case private registries are configured, we always provide a specific list of feeds to dotnet restore to make sure that we include the private registries.
  • Adjust the telemetry for All NuGet feeds reachable. Previously, we only considered a feed to be unreachable in case there was a timeout. Now other errors like 401/403 are included.
  • Due to the changes mentioned above, the changes to the output of the integration test standalone_dependencies_nuget_config_error are expected. As the feed in the nuget.config is it not reachable it means that
    • All NuGet feeds reachable is false (and thus 0 is reported).
    • Failed project restore with package source error is now 0 as the restore process now excludes the unreachable feed from the nuget.config file (and instead we get another NuGet error as the restore process attempts to find the NewtonSoft.Json package in the empty folder).

The fallback in case there is a timeout on an explicit feed has been kept in the implementation. I think we should consider removing this fallback (it was made prior to any of the logic, which overrides the nuget.config files) and just rely on supplying the reachable feeds to the dotnet restore process.

The documentation for the -s (NuGet source) can be seen here.

I encourage to review all the changes in this PR in one go (review by commit is NOT encouraged as there is some going back and forth due to experimentation).

DCA looks good; For our existing suite there doesn't appear to be any regressions. However, I expect improved performance in cases where there are issues with connecting to the feeds.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants