[英]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.