C#: Use feed management in the remaining restore flows. - #22041
Conversation
25ade27 to
afe8f07
Compare
29a859a to
036f75c
Compare
036f75c to
86fc08e
Compare
4690d92 to
6ee50ce
Compare
43aaec6 to
fde527a
Compare
bbc01c9 to
b0eaf49
Compare
b0eaf49 to
a66f82e
Compare
…apsulate as immutable hash sets.
…mmutable hash sets).
…lays the calculation of the reachable feeds until it is needed/used.
…mSpecificFeeds as it is always called with this argument.
…instead of a specific nuget.config file, and supply a list of nuget sources when using the TryRestore.
a66f82e to
b34fe44
Compare
There was a problem hiding this comment.
Pull request overview
Centralizes NuGet feed selection in FeedManager across remaining C# dependency restore flows.
Changes:
- Adds lazy feed discovery and reachability management.
- Passes feeds directly to restore commands.
- Removes fallback
nuget.configgeneration.
Show a summary per file
| File | Description |
|---|---|
2026-07-17-nuget-package-restore.md |
Documents restore changes. |
Semmle.Extraction.Tests/DotNet.cs |
Updates restore argument tests. |
PackagesConfigRestorer.cs |
Uses managed feed selection. |
NugetPackageRestorer.cs |
Migrates remaining restore flows. |
IDotNet.cs |
Removes config-path setting. |
FeedManager.cs |
Centralizes feed state and reachability. |
DotNet.cs |
Removes --configfile handling. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (1)
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs:324
- The newly introduced unchecked-feed fallback is not exercised by the existing fallback integration tests; they all leave responsiveness checking enabled. Please add coverage that disables feed checking and verifies a missing package is restored through
AllFeeds, including the intended configured/private-feed behavior.
else
{
feeds = feedManager.AllFeeds;
}
- Files reviewed: 7/7 changed files
- Comments generated: 3
- Review effort level: Balanced
hvitved
left a comment
There was a problem hiding this comment.
LGTM, some minor comments.
| /// <summary> | ||
| /// Gets the list of inherited NuGet feeds that are configured in the environment. | ||
| /// </summary> | ||
| public ImmutableHashSet<string> InheritedFeeds => AllFeeds.Except(ExplicitFeeds).ToImmutableHashSet(); |
There was a problem hiding this comment.
Would it make the code cleaner if the logic populated this hash set and AllFeed was then defined as the union of ExplicitFields and InheritedFields?
There was a problem hiding this comment.
I don't think there is an easy way to calculate InheritedFeeds in another way than AllFeeds\ExplicitFeeds
| /// <summary> | ||
| /// Gets whether there was a timeout when checking the reachability of the explicitly configured NuGet feeds. | ||
| /// </summary> | ||
| public bool ExplicitFeedTimeout => lazyReachableExplicitFeeds.Value.Item1; |
There was a problem hiding this comment.
Could this instead be ReachableExplicitFeeds.Count() == ExplicitFields.Count() and then we can avoid the tuple construction?
There was a problem hiding this comment.
Unfortunately not. The set of ReachableExplicitFeeds are the feeds where we have confirmed that we can connect. That is, ReachableExplicitFeeds doesn't contain feeds where we e.g. get 401/403 errors (or other errors). The timeout boolean only refers to a timeout. This means that we could have ReachableExplicitFeeds.Count() != ExplicitFields.Count() and timeout = false.
There is also a follow up PR for getting rid of the ExplicitFeedTimeout altogether: #22094
| --- | ||
| category: majorAnalysis | ||
| --- | ||
| * Simplified and streamlined the use of NuGet sources when downloading dependencies. In fallback scenarios and specialized package downloads, NuGet sources are now passed directly to `dotnet restore` via `-s`. Furthermore, no `nuget.config` files are created for fallback scenarios, and private registries are used when attempting to download missing packages that were not restored as part of the normal `dotnet restore` process. |
There was a problem hiding this comment.
The dotnet restore -s change seems like an internal implementation detail that customers should not care about?
There was a problem hiding this comment.
We can remove the mention of -s, but I think we need to mention that feeds are provided directly to the restore command (If this change for some reason break something)
|
@hvitved : Made a small update to the change note. Could you re-approve? 😄 |
The primary purpose of this PR is to use the newly introduced feed manager in more of the package restore flows.
To achieve this we are
DowloadMissingPackages. This also somewhat simplifies the restore logic as we no longer create a dedicatednuget.configfile in fallback scenarios, but instead we supply feeds directly via the command line. Furthermore, if NuGet feed responsiveness checking is disabled we use all feeds when attempting to download missing packages (this will include private registries as well).TryRestoremethod, which can be used to restore individual packages. The logic has been changed slightly here compared to earlier as we will attempt to use the feeds detected in the source directory (instead of those in the temporary directory).With the changes in this PR, all
restorelike flows specify the feeds directly via the command line (unless NuGet feed checking is disabled and no private registries are configured). That is, as a follow up we can attempt the remove the timeout fallback and instead just always use reachable feeds.Testing