Skip to content

C#: Use the feed manager in the NugetExeWrapper.#22033

Open
michaelnebel wants to merge 5 commits into
github:mainfrom
michaelnebel:csharp/usefeedmanager
Open

C#: Use the feed manager in the NugetExeWrapper.#22033
michaelnebel wants to merge 5 commits into
github:mainfrom
michaelnebel:csharp/usefeedmanager

Conversation

@michaelnebel

@michaelnebel michaelnebel commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Just like for dotnet restore is it possible to specify the NuGet sources directly when using the nuget.exe CLI. The documentation for the NuGet CLI can be seen here and it states that it is possible to add (multiple) sources by providing (multiple) -Source arguments.

In this PR we simplify and streamline the use nuget sources when downloading dependencies using [mono] nuget.exe. That is, we

  • No longer attempt to move/create nuget.config files in the checked out repo. Instead we supply the sources with the -Source.
  • Make use of private registries if such are configured.
  • Only use reachable feeds in case NuGet feed checking is enabled (which it is by default).

It is worth noting that we start to use dotnet nuget to detect the sources needed for the restore.

@github-actions github-actions Bot added the C# label Jun 22, 2026
@michaelnebel

Copy link
Copy Markdown
Contributor Author

DCA looks good.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the C# dependency fetching pipeline so packages.config restores performed via nuget.exe use the existing FeedManager (consistent with dotnet restore) and can pass multiple package sources via repeated -Source arguments, aligning with NuGet CLI behavior.

Changes:

  • Refactors packages.config restore to use FeedManager for determining restore sources instead of editing nuget.config.
  • Introduces shared feed-selection helpers (FeedsToUse, generalized FeedsToRestoreArgument) and updates dotnet restore to use the renamed source-argument builder.
  • Simplifies IPackagesConfigRestore by removing IDisposable and associated config backup/restore logic.
Show a summary per file
File Description
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/PackagesConfigRestorer.cs Switch nuget.exe-based packages.config restore to compute -Source args from FeedManager rather than mutating nuget.config.
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs Wires the new FeedManager-driven packages.config restore and updates dotnet restore source-argument method usage.
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs Adds reusable feed selection (FeedsToUse) and generalizes source-argument generation across restore tools.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 4

Comment on lines +175 to +176
var feedsToUse = feedManager.FeedsToUse(packagesConfig, reachableFeeds).ToList();
var useDefaultFeed = feedsToUse.Count == 0 && IsDefaultFeedReachable;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also use the default feed for windows (if it is reachable and we don't find any other feeds). The PR where this was originally introduced states, that this case was implemented specifically for MacOS 14, because there is no user/machine specific feed on that image (which can explain why Windows was excluded). Most likely our windows images will have user/machine defaults, but I don't think we should assume that in our implementation.

Comment thread csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs Outdated
Comment thread csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs Outdated
@michaelnebel michaelnebel force-pushed the csharp/usefeedmanager branch from d8fa611 to 9bce72a Compare June 24, 2026 13:32
@michaelnebel

Copy link
Copy Markdown
Contributor Author

Running DCA again. It might be worth running a QA experiment for this PR as well.

@michaelnebel michaelnebel marked this pull request as ready for review June 24, 2026 13:53
@michaelnebel michaelnebel requested a review from a team as a code owner June 24, 2026 13:53
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.

3 participants