Is there a way to view which package source an ins

2019-06-20 04:34发布

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

1条回答
乱世女痞
2楼-- · 2019-06-20 04:57

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.

查看更多
登录 后发表回答