question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add --configfile switch to dotnet list package

See original GitHub issue

Is your feature request related to a problem? Please describe.

I am cloning repositories in an Azure DevOps pipeline from multiple organisations to search for package issues (deprecated, outdated and vulnerable dependencies). I determine the possible Azure Artifact feeds that may be involved in running dotnet CLI commands against that repository and dynamically generate a nuget.config file.

Running dotnet restore '{csprojpath}' --configfile '{temppath}/nuget.config' --ignore-failed-sources works completely fine. Part of the log output of the restore includes this:

  NuGet Config files used:
      /agent/_work/_temp/feedconfig/{someorg}/{someproject}/nuget.config
  
  Feeds used:
      https://api.nuget.org/v3/index.json
      https://pkgs.dev.azure.com/{someorg}/{someprojectid}/_packaging/{projectfeedid}/nuget/v3/index.json
      https://pkgs.dev.azure.com/{someorg}/_packaging/{orgfeedid}/nuget/v3/index.json

The dotnet list {csprojpath} package CLI commands do not support a --configfile switch and I cannot get it to consult those feeds. For example, I run dotnet list {csprojpath} --outdated and I get the following in the output:

The following sources were used:
   https://api.nuget.org/v3/index.json

  CACHE https://api.nuget.org/v3/registration5-gz-semver2/microsoft.azure.functions.worker/index.json
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/microsoft.azure.functions.worker.extensions.http/index.json
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/microsoft.azure.functions.worker.extensions.storage/index.json
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/microsoft.azure.functions.worker.sdk/index.json
  GET https://api.nuget.org/v3/registration5-gz-semver2/{myinternalpackage}/index.json
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/system.text.regularexpressions/index.json
  NotFound https://api.nuget.org/v3/registration5-gz-semver2/{myinternalpackage}/index.json 401ms
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/microsoft.azure.functions.worker/index.json
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/microsoft.azure.functions.worker.extensions.http/index.json
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/microsoft.azure.functions.worker.extensions.storage/index.json
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/microsoft.azure.functions.worker.sdk/index.json
  GET https://api.nuget.org/v3/registration5-gz-semver2/{myinternalpackage}/index.json
  CACHE https://api.nuget.org/v3/registration5-gz-semver2/system.text.regularexpressions/index.json
  NotFound https://api.nuget.org/v3/registration5-gz-semver2/{myinternalpackage}/index.json 280ms
Project `{MyProject}` has the following updates to its packages
   [net6.0]: 
   Top-level Package                  Requested   Resolved   Latest                  
   > {MyInternalPackage}      1.0.0       1.0.0      Not found at the sources

Describe the solution you’d like

dotnet list supports the --configfile switch so that we can be explicit on the CLI regarding which feeds to consume for that operation.

Additional context

I have tried running the dotnet CLI commands with the working directory that contains nuget.config. I have also tried installing the artifacts credential provider and building the VSS_NUGET_EXTERNAL_FEED_ENDPOINTS environment variable. Nothing I have done will get dotnet list package to check the feeds in my custom nuget.config.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
roryprimrosecommented, Feb 18, 2022

The -config switch works as expected. My scanning is now consulting our internal AzDO feeds.

1reaction
baronfelcommented, Feb 18, 2022

I agree on the documentation, but one thing I want to work towards is having a consistent set of options for the same concepts across operations. Every operation that takes MSBuild parameters needs to support -p, every operation that is backed by NuGet needs to support a config file by some shared name. --config and --configfile being separate in these two commands is just annoying enough to make me want to unify it, that’s all I mean.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet nuget add source command - .NET CLI
The dotnet nuget add source command adds a new package source to your NuGet configuration files.
Read more >
Missing packages.config file - net core
In dotnet core, packages are declared inside of the csproj file, as "PackageReference" The overall idea of a packages.config does not exist in ......
Read more >
Dotnet restore vs nuget restore. Share. In my code repo, there
I believe you want to use dotnet nuget add source: How to use an API Key with ... packages from 'Default Project' list;...
Read more >
Managing Dependencies in .NET: .csproj, .packages.config ...
Get an overview of the artifacts involved in .NET dependency management, how they interact, and how to use them.
Read more >
NuGet packages in the Package Registry
config file. Install the latest version of a package by running this command: dotnet add package <package_id> \ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found