Repository navigation
C#: Don't use the NuGet CLI for restoring packages.config in case private registries are configured.
#22911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
C#: Don't use the NuGet CLI for restoring packages.config in case private registries are configured.
#22911
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ internal class PackagesConfigRestoreFactory | |
| { | ||
| public static IPackagesConfigRestore Create(IFileProvider fileProvider, DependencyDirectory packageDirectory, Semmle.Util.Logging.ILogger logger, FeedManager feedManager) | ||
| { | ||
| if (SystemBuildActions.Instance.IsWindows() || SystemBuildActions.Instance.IsMonoInstalled()) | ||
| if ((SystemBuildActions.Instance.IsWindows() || SystemBuildActions.Instance.IsMonoInstalled()) && !feedManager.HasPrivateRegistryFeeds) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a good point (co-incidentally I was looking into converting the FileContent parser to XML as well), but that is a general improvement as well and out of scope for this PR.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| { | ||
| return new NugetExeWrapper(fileProvider, packageDirectory, logger, feedManager); | ||
| } | ||
|
|
@@ -252,7 +252,7 @@ public int InstallPackages() | |
| { | ||
| if (PackageCount > 0) | ||
| { | ||
| logger.LogInfo("Found packages.config files, but nuget.exe cannot be used to restore packages on this platform. Skipping restore of packages.config files."); | ||
| logger.LogInfo("Found packages.config files, but nuget.exe cannot be used to restore packages on this platform or if private registry feeds are configured. Skipping restore of packages.config files."); | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
|
|
||
| - When private NuGet registries are configured, the extractor only attempts to restore dependencies listed in `packages.config` files using `dotnet restore` instead of the NuGet CLI so that the private registry configuration is respected. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When private registries are configured, we assume that these registries will contain the access to the bulk of the dependencies, which means that any attempt to restore a package using the NuGet CLI will most likely fail with an unauthorized error.
It would be a good improvement, if we also made the
dotnet restorelogic version aware, but it is out of scope for this PR.