【问题标题】:NuGet errors in Package Manager Console on MVC 3 File, New ProjectMVC 3 文件、新项目的包管理器控制台中的 NuGet 错误
【发布时间】:2011-04-20 17:08:26
【问题描述】:

所以我安装了新的 MVC3 工具更新并尝试创建一个新的 MVC3 Web 应用程序。该项目报告为已成功创建,但如果我打开包管理器控制台,我会看到以下内容...

加载扩展类型数据文件时出现以下错误:, D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.2.20325.9034\Scripts\NuGet .Types.ps1xml :由于以下验证异常而跳过文件:文件 D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.2.20325.9034\Scripts\NuGet。无法加载 Types.ps1xml。文件 D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.2.20325.9034\Scripts\NuGet.Types.ps1xml 未进行数字签名。该脚本不会在系统上执行。有关更多详细信息,请参阅“get-help about_signing”... 加载格式数据文件时出错:D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.2.20325.9034\Scripts\NuGet.Format.ps1xml, , D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.2.20325.9034\Scripts\NuGet.Format.ps1xml :由于以下验证异常而跳过文件:文件 D :\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.2.20325.9034\Scripts\NuGet.Format.ps1xml 无法加载。文件 D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.2.20325.9034\Scripts\NuGet.Format.ps1xml 未进行数字签名。该脚本不会在系统上执行。有关详细信息,请参阅“get-help about_signing”...

所以这里似乎出现了两个错误,一个是在尝试加载扩展数据文件时,一个是在加载格式数据文件时。

我已经安装了 powershell 2.0。有人有想法么?我应该关心项目是否成功创建(我认为)?

【问题讨论】:

  • 如果你打开一个 powershell 提示符并运行 Get-ExecutionPolicy,它会说什么?如果您重置 VS 并创建新的 MVC 应用程序,是否会看到此错误?
  • Get-ExecutionPolicy 报告 RemoteSigned。不是PS专家,所以不确定这是好是坏。好消息是,显然只需重新启动 VS(两次)就可以了。一定是一些奇怪的文件句柄没有释放。

标签: visual-studio-2010 asp.net-mvc-3 powershell nuget nuget-package


【解决方案1】:

您是如何安装 NuGet 的?

我只是在与一个类似的错误搏斗,这是因为我在提取之前没有先在 zip 文件的属性中单击“取消阻止”就提取了 Powershell 模块。这意味着所有文件都被标记为来自互联网,并且 RemoteSigned 不允许运行未签名的远程文件。

导航到包含上述文件的文件夹,然后打开它们的“属性”对话框,查看是否有一条消息显示“此文件来自互联网”并带有“取消阻止”按钮。如果是这样,请为每个文件单击它,然后重试。

【讨论】:

  • 好提示。我将 NuGet 作为 MVC 3 工具更新的一部分。没有带有解锁按钮的消息,但它可能是在它开始工作之前设置的。
  • 现在,有一种更简单的方法可以解决这个问题。临时更改 powershell 的执行策略以允许运行从互联网下载的脚本。 powershell -ExecutionPolicy ByPass -File script-to-run.ps1
【解决方案2】:

由于某种原因,我经常遇到类似的问题。所有 NuGet 文件均已解锁,仅重新启动 VS(通过打开 sln 文件)并不能修复它。什么是自己打开 Visual Studio,而不加载解决方案,然后打开包管理器控制台,然后然后打开解决方案。

【讨论】:

    【解决方案3】:

    对我来说,这个错误是由 .Net Reflector(免费版)引起的。 使用插件管理器禁用它,我很好。

    【讨论】:

      【解决方案4】:

      我有同样的错误! 我的解决方案非常简单。当您尝试打开解决方案时,只需右键单击 Visual Studio 并选择“以管理员身份运行”。

      【讨论】:

        【解决方案5】:

        我相信您需要以管理员身份运行 Visual Studio。

        在 Package Manager 控制台中,您可以查看 Powershell 的执行策略。键入“获取执行策略”。默认情况下,它将是一个类似于“RemoteSigned”的值。 MvcScaffolding 已签名,因此它将在此策略下运行。

        这是一个包含更多信息的网址: http://technet.microsoft.com/en-us/library/dd347649.aspx

        以下是记录的各种执行策略: http://technet.microsoft.com/en-us/library/dd347628.aspx

        这是第一个链接的摘录: 如果您尝试运行下载的脚本,Windows PowerShell 会显示 以下错误信息:

            The file <file-name> cannot be loaded. The file 
            <file-name> is not digitally signed. The script
            will not execute on the system. Please see "Get-Help
            about_signing" for more details.
        
        Before you run the script, review the code to be sure that you trust it.
        Scripts have the same effect as any executable program.
        
        To run an unsigned script:
        
            1. Save the script file on your computer. 
            2. Click Start, click My Computer, and locate the saved script file. 
            3. Right-click the script file, and then click Properties. 
            4. Click Unblock.
        
        If a script that was downloaded from the Internet is digitally signed, but
        you have not yet chosen to trust its publisher, Windows PowerShell displays
        the following message:
        
            Do you want to run software from this untrusted publisher? 
            The file <file-name> is published by CN=<publisher-name>. This 
            publisher 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"):
        
            If you trust the publisher, select "Run once" or "Always run." 
            If you do not trust the publisher, select either "Never run" or 
            "Do not run." If you select "Never run" or "Always run," Windows
            PowerShell will not prompt you again for this publisher.
        

        希望对您有所帮助。

        【讨论】:

          【解决方案6】:

          您可能只想将 Powershell 执行策略更改为不受限制。请参阅此 Microsoft 知识库文章 KB 2411920

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2013-04-15
            • 1970-01-01
            • 2012-05-10
            • 2013-01-08
            • 2015-05-19
            相关资源
            最近更新 更多