简体   繁体   English

将 Visual Studio Package 管理器控制台用于其他解决方案

[英]Using Visual Studio Package Manager Console for other solution

My source code is composed of many solutions .我的源代码由许多解决方案组成。 In order to collect information on the installed packages (version, license, etc.) of each solution, I'm looking for a way to organize it automatically.为了收集有关每个解决方案的已安装包(版本、许可证等)的信息,我正在寻找一种自动组织它的方法。 As I know so far there is an option to use the Get-Package command via the Visual Studio Package Manager Console, or to use the do.net list package command据我所知,目前有一个选项可以通过 Visual Studio Package 管理器控制台使用Get-Package 命令,或者使用do.net list package 命令

The problem:问题:

Get-Package - Seems to be available only from a specific solution and only for this specific solution. Get-Package - 似乎只能从特定解决方案中获得,并且仅适用于该特定解决方案。 Since I have many solutions it's not a trivial solution因为我有很多解决方案,所以这不是一个简单的解决方案

do.net list package - It gets a solution as a parameter so I can run it on every solution, bu it works only for the new csproj files, but I have many old csproj files do.net list package - 它获取一个解决方案作为参数,因此我可以在每个解决方案上运行它,但它仅适用于新的csproj文件,但我有许多旧的csproj文件

The preferred way for me is to use the Powershell command available in the console since I have the option to get the license URL from it by using this command:我的首选方法是使用控制台中可用的 Powershell 命令,因为我可以选择使用以下命令从中获取许可证 URL:

Get-Package | Select-Object Id, Version, LicenseUrl, ProjectName

Is there a way to run the above command in one solution for all other solutions (assuming I can get easily the solutions list) or it requires to run only from a specific solution each time?有没有办法在所有其他解决方案的一个解决方案中运行上述命令(假设我可以轻松获得解决方案列表),或者每次只需要从特定解决方案运行?

If you want to use do.net list package to get packages from your solution which includes old and new csproj , you can migrate from packages.config to PackageReference.如果您想使用do.net list package从您的解决方案中获取包括旧的和新的csproj的包,您可以从 packages.config 迁移到 PackageReference。 Please refer to doc: Migrate .请参考文档: 迁移

But there are some Limitations: Migration is not currently available for C++ and ASP.NET projects.但也有一些局限性: 目前无法迁移 C++ 和 ASP.NET 项目。

Notice: You'd better make backup before migration to prevent unexpected effects of upgrades注意:迁移前最好做好备份,以免升级造成意外影响

If you want to use Get-Package to get packages for other solutions, you can add Parameter ListAvailable to list packages available from a package source.如果要使用Get-Package获取其他解决方案的包,可以添加参数ListAvailable以列出 package 源中可用的包。 Suppose the packages you download in your multiple solutions are from nuget.org, you can set nuget.org as package source.假设您在多个解决方案中下载的包来自nuget.org,您可以将nuget.org设置为package源。 It will return all packages in multiple solutions from specified source.它将从指定源返回多个解决方案中的所有包。

For example例如

Get-Package  -ListAvailable | Select-Object Id, Version, ProjectName,LicenseUrl

RESULT结果

结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio 2012程序包管理器控制台名称不能以&#39;&lt;&#39;字符开头 - Visual studio 2012 package manager console Name cannot begin with the '<' character NuGet(NuPack)intellisense(Visual Studio包管理器控制台) - NuGet (NuPack) intellisense (Visual Studio Package Manager Console) Visual Studio - 包管理器控制台 - 以编程方式运行命令 - Visual Studio - Package Manager Console - Running commands programmatically Visual Studio包管理器控制台迁移拒绝使用连接字符串 - Visual studio package manager console migrations refuse to use connection string 如何使用NuGet软件包管理器控制台在Visual Studio 2012 Pro上安装OpenPop.NET? - How can i install OpenPop.NET on my visual studio 2012 pro using the NuGet package manager console? Package 管理器控制台未显示 - Package manager console not showing 包管理器控制台问题 - Package Manager Console issues 包管理器控制台不工作 - Package Manager console not working NuGet 包管理器 - 未找到项目“默认”。 - 视觉工作室 2017 - NuGet Package Manager - Project 'Default' is not found. - Visual Studio 2017 在不使用 Visual Studio 的情况下清理和构建解决方案 - Clean and Build a solution without using Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM