Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to view which package source an installed NuGet package is from, in Visual Studio?

In Visual Studio's NuGet Package Manager, you can view which NuGet packages have been installed in a solution by clicking the "Installed" tab in the package manager.

However, in situations where the same package is in multiple NuGet Package Sources, it would be useful to see which package source a particular NuGet package has come from. Is there a way to see this in the NuGet Package Manager, or any where else in VS?

Edit: Copying in my comment below for clarification:

I'm creating a project using a preexisting one as a model. Both projects will need to reference the same Nuget packages, so I open up the model project in Visual Studio, open the Nuget Package Manager, and look at its installed packages. The model project has "PackageA" installed. I open the new project, open the Nuget Package Manager for it, and Browse for "PackageA". I notice that "PackageA" is available in multiple Package Sources. (These are internal to my company, not nuget,org) In my new project, I'd like to install "PackageA" from the same Package Source as the model project

like image 840
BobbyA Avatar asked Jun 27 '17 19:06

BobbyA


People also ask

How do I find the source of a NuGet package?

You can find packages directly at https://nuget.org/packages, or from the Visual Studio Package Manager UI or Package Manager Console with nuget.org as a source.


1 Answers

Is there a way to view which package source an installed NuGet package is from, in Visual Studio?

The simple answer is No. That is because the information about which NuGet packages have been installed in a solution by in the "Installed" tab in the package manager is based on the packages.config file. There are only package ID, version, targetFramework options in that file, so we could get the NuGet Package Sources info in the package manager based on the Packages.config.

Besides, when we use NuGet to manage our packages, NuGet will download the packages from the NuGet Package Sources and set those packages into the Packages folder in the solution folder. What we have to do next are related to the packages in the Packages folder rather than NuGet Package Sources (except NuGet restore, Restore just download the packages from NuGet Package Sources). So we could not find the package source only be based on a package which has been downloaded already without package source info in the Package.config.

What`s more, when we use NuGet to download the packages, NuGet will search the NuGet Package Sources one by one to download, NuGet could not be smart to store the Package Sources where each package download from.

I'd like to install "PackageA" from the same Package Source as the model project

To resolve this question, you can open the Packages folder, copy "PackagesA", set it to the NuGet Package Source which you want to use, then install "PackageA" from that Package Source, you will get the same package as the model project.

like image 156
Leo Liu-MSFT Avatar answered Sep 24 '22 11:09

Leo Liu-MSFT