NuGet execution policy errors when installing MvcScaffolding package

血红的双手。 提交于 2019-12-05 19:48:59
asgeo1

OK, I have MvcScaffolding installed correctly now.

I had to first bypass all security in NuGet:

Set-ExecutionPolicy Bypass -Scope Process

But when I restart Visual Web Developer I still get those same PowerShell errors todo with the NuGet running init.pls on startup.

I've worked out that it's because I was storing my project on a network drive. Apparently PowerShell won't execute scripts from the network drive by default.

I tried using CasPol to change the security settings, but couldn't get it to work. I gave up when I saw other people couldn't get VS to work with mapped drives as well:

CAS not working for VS2010 mapped drive

Anyway, I just have my project local now, and MvcScaffolding is installed and working.

You can set the policy for user scope and using a more secure policy like this:

Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope CurrentUser

Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer. Prompts you before running scripts from publishers that you have not yet classified as trusted or untrusted.

For exemple, installing a EntityFramework ask permission to run the script:

Executing script file 'c:\users\user\documents\visual studio 2015\Projects\zzz\packages\EntityFramework.6.1.3\tools\install.ps1'
Do you want to run software from this untrusted publisher?
File C:\users\user\documents\visual studio 2015\Projects\zzz\packages\EntityFramework.6.1.3\tools\install.ps1 is published by CN=Microsoft Corporation, OU=MOPR, O=Microsoft Corporation, L=Redmond, S=Washington, C=US and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run  [D] Do not run  [R] Run once  [A] Always run  [?] Help (default is "D"):R
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!