简体   繁体   中英

How to use Package Manager Console powershell outside visual studio

I have a powershell script which has nuget commands like:

Get-Project -All

Get-Package -ProjectName

When I run package manager console on visual studio like:

PM> .\\download-packages-license.ps1

It worked but I cannot run powershell. I need a hlp.

Powershell error message:

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

I am afraid you could not use Package Manager Console powershell outside visual studio. That because package manager console is providing is access to visual studio objects :

https://github.com/NuGet/Home/issues/1512

So, if you want use Package Manager Console powershell outside visual studio, we have to parse the .csproj file or .sln solution file with powershell manually, like:

How do I programmatically list all projects in a solution?

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM