Nuget给出此错误“由于无法运行脚本,因此无法加载ps1".

问题描述:

我有一个新的空MVC 5项目,我尝试安装Nuget软件包. 当我在Nuget控制台中插入命令:Update-Package时,我得到了以下提示:

I have a new empty MVC 5 project, and I try to install Nuget packages. When I insert in the Nuget Console the command :Update-Package I got the following asnwer:

File E:\WebApp\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\tools\uninstall.ps1 cannot be loaded because running scripts is 
disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.At line:1 char:3
+ & 'E:\WebApp\packages\Microsoft.CodeDom.Providers.Dot ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

然后我开始安装一些新软件包,并再次收到以下消息:

then I start to install some new packages and got again this message:

由于无法在此系统上禁用运行脚本,因此无法加载WebApp \ packages \ Modernizr.2.8.3 \ tools \ install.ps1

我看到了一些与此消息相关的帖子,但与MVC项目无关.

I saw some posts related with this message, but not related with MVC projects.

我的问题是:

为什么我收到那些消息?

Why I get those messages?

我该怎么做才能解决此问题?

What can I do to fix this issue?

此问题可以在运行我的应用程序的服务器上出现吗?一些脚本无法按预期运行?

This issue, can appear on the server where my application will run? Some scripts to not run as expected?

我想您尝试安装的特定软件包需要运行Powershell脚本,并且由于某些原因,您的计算机上禁用了Powershell执行. 您可以在Google的如何启用Powershell"中搜索完整的指南,但通常情况如下:

I guess the specific package you are trying to install needs to run a Powershell script and for some reason, Powershell execution is disabled on your machine. You can search google on "how to enable Powershell" for a complete guide but generally, it goes like this:

  • 打开Powershell命令窗口(只需在按下Windows的开始"按钮后搜索Powershell)
  • 通过键入Get-ExecutionPolicy
  • 查看当前限制
  • 通过键入Set-ExecutionPolicy remotesigned
  • 启用PowerShell
  • Open up a Powershell command window (just search for Powershell after pressing windows start button)
  • Check out current restrictions by typing Get-ExecutionPolicy
  • Enable PowerShell by typing Set-ExecutionPolicy remotesigned

此问题不会影响您计划在其上安装应用程序的服务器.

This issue does not affect the server you are planing to install your application on.