asp.net-mvc - Nuget给出错误 “ps1 cannot be loaded because running scripts is disabled”

标签 asp.net-mvc powershell nuget

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

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

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

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

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

我的问题是:

为什么我收到这些消息?

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

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

最佳答案

我想您要安装的特定软件包需要运行Powershell脚本,并且由于某种原因,您的计算机上禁用了Powershell执行。
您可以在“如何启用Powershell”上搜索google以获得完整指南,但通常情况如下:

  • 打开Powershell命令窗口(只需在按下Windows开始按钮后搜索Powershell)
  • 通过键入Get-ExecutionPolicy
  • 查看当前限制
  • 通过键入Set-ExecutionPolicy remotesigned
  • 启用PowerShell

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

    关于asp.net-mvc - Nuget给出错误 “ps1 cannot be loaded because running scripts is disabled”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32692087/

    相关文章:

    asp.net - 在 Visual Studio 2010 (MVC3) Web 项目中默认使用 IIS Express?

    c# - Visual Studios 使用 ASP 项目启动错误的 URL?

    c# - 使用 C# 中的调用命令抛出异常

    powershell - Jenkins:在不知道节点 secret 的情况下动态地将奴隶连接到主人

    使用 VSTS 进行 NuGet 自动版本控制

    msbuild - nuget 包路径中的非法字符

    jquery - 来自 Asp.net mvc 的大型 html 页面

    asp.net-mvc - 将 razor View 渲染为字符串而不修改 html

    powershell - 在 powershell 中仅提取 csv 文件的前 10 行

    .net - 安装包 : The remote name could not be resolved: 'packages.nuget.org'