如何在 visual studio 之外使用包管理器控制台 powershell
How to use Package Manager Console powershell outside visual studio
我有一个 powershell 脚本,其中包含如下 nuget 命令:
Get-Project -All
Get-Package -ProjectName
当我在 visual studio 上 运行 程序包管理器控制台时,我喜欢:
PM> .\download-packages-license.ps1
它有效,但我无法 运行 powershell。我需要帮助。
Powershell 错误信息:
download-packages-license.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/
fwlink/?LinkID=135170.
At line:1 char:1
+ .\download-packages-license.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
How to use Package Manager Console powershell outside visual studio
恐怕您无法在 visual studio 之外使用包管理器控制台 powershell。那是因为包管理器控制台提供了对 visual studio 对象:
的访问
https://github.com/NuGet/Home/issues/1512
因此,如果您想在 visual studio 之外使用包管理器控制台 powershell,我们必须使用 powershell 手动解析 .csproj
文件或 .sln
解决方案文件,例如:
How do I programmatically list all projects in a solution?
希望对您有所帮助。
我有一个 powershell 脚本,其中包含如下 nuget 命令:
Get-Project -All
Get-Package -ProjectName
当我在 visual studio 上 运行 程序包管理器控制台时,我喜欢:
PM> .\download-packages-license.ps1
它有效,但我无法 运行 powershell。我需要帮助。
Powershell 错误信息:
download-packages-license.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/ fwlink/?LinkID=135170. At line:1 char:1 + .\download-packages-license.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
How to use Package Manager Console powershell outside visual studio
恐怕您无法在 visual studio 之外使用包管理器控制台 powershell。那是因为包管理器控制台提供了对 visual studio 对象:
的访问https://github.com/NuGet/Home/issues/1512
因此,如果您想在 visual studio 之外使用包管理器控制台 powershell,我们必须使用 powershell 手动解析 .csproj
文件或 .sln
解决方案文件,例如:
How do I programmatically list all projects in a solution?
希望对您有所帮助。