如何确定在 Powershell 的 Visual Studio 程序包管理器控制台中选择的默认项目?

How do I determine the default project selected in the Visual Studio Package Manager Console in Powershell?

我正在编写一些将放在 Nuget 包中的 Powershell 脚本,然后我将从包管理器控制台 运行。这些脚本将 运行 在包管理器控制台的 "Default Project" 下拉列表中选择的项目中的所有测试。我的问题是,如何确定(在 Powershell 中)当前在包管理器控制台中选择了哪个项目?

Package Manager Console Screenshot

您可以使用 $proj 在程序包管理器控制台中确定默认项目。您可以通过在程序包管理器控制台中键入 write-host $proj.Name 并按 Enter 来验证项目名称。这将在包管理器控制台中显示默认项目名称。希望这对您有所帮助!

There are a number of useful commands available to you in the Package Manger Console, one of which is:

Get-Project which on its own will give you the name of the Default project in the Package Manager Console. However:

Get-Project -All Produces a list of all the projects in the currently loaded solution.

http://www.edcourtenay.co.uk/musings-of-an-idiot/list-referenced-nuget-packages-from-the-package-manager-console