有没有办法在Visual Studio中查看已安装的NuGet软件包来自哪个软件包源? [英] Is there a way to view which package source an installed NuGet package is from, in Visual Studio?

查看:390
本文介绍了有没有办法在Visual Studio中查看已安装的NuGet软件包来自哪个软件包源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio的NuGet程序包管理器中,您可以通过单击程序包管理器中的已安装"选项卡来查看解决方案中已安装了哪些NuGet程序包.

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.

但是,在同一软件包位于多个NuGet软件包源中的情况下,查看特定NuGet软件包来自哪个软件包源将很有用.是否可以在NuGet程序包管理器中或VS中的其他任何位置查看此内容?

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?

修改: 复制以下我的评论以进行澄清:

Copying in my comment below for clarification:

我正在使用一个已经存在的项目作为模型来创建一个项目.这两个项目都需要引用相同的Nuget软件包,因此我在Visual Studio中打开模型项目,打开Nuget软件包管理器,然后查看其已安装的软件包.模型项目已安装"PackageA".我打开新项目,为其打开Nuget软件包管理器,然后浏览"PackageA".我注意到"PackageA"在多个包源中可用. (这些是我公司内部的文件,而不是nuget,org).在我的新项目中,我想从与模型项目相同的Package Source中安装"PackageA"

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

推荐答案

是否可以在Visual Studio中查看已安装的NuGet软件包来自哪个软件包源?

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

简单的答案是否".这是因为有关程序包管理器中已安装"选项卡中解决方案中已安装哪些NuGet程序包的信息基于packages.config文件.该文件中只有软件包ID, version, targetFramework选项,因此我们可以基于Packages.config在软件包管理器中获取NuGet软件包源信息.

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.

此外,当我们使用NuGet管理软件包时,NuGet将从NuGet软件包源中下载软件包并将这些软件包设置到解决方案文件夹中的Packages文件夹中.接下来,我们要做的是与Packages文件夹中的软件包相关,而不是与NuGet软件包源相关(NuGet还原除外,Restore只是从NuGet软件包源中下载软件包).因此,我们无法找到仅基于已经下载的软件包的软件包源,而在Package.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.

更重要的是,当我们使用NuGet下载软件包时,NuGet会逐一搜索NuGet软件包源以进行下载,NuGet 不能聪明地将软件包源存储在每个软件包的位置从下载.

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.

我想从与模型项目相同的Package Source中安装"PackageA"

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

要解决此问题,您可以打开Packages文件夹,复制"PackagesA",将其设置为要使用的NuGet软件包源,然后从该软件包源安装"PackageA",您将获得与模型项目相同的软件包.

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.

这篇关于有没有办法在Visual Studio中查看已安装的NuGet软件包来自哪个软件包源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆