c# - 在 ASP.NET MVC 6 中更新 NuGet 包

标签 c# asp.net asp.net-mvc nuget asp.net-core-mvc

我刚刚创建了一个新的 ASP.NET MVC 6 项目,并想将 NuGet 包更新到最新版本(默认项目模板通常已经过时)。我注意到可以进行以下更新:

  • Antlr.3.4.1.9004 > Antlr.3.5.0.2
  • Newtonsoft.Json.6.0.4 > Newtonsoft.Json.6.0.8
  • WebGrease.1.5.2 > WebGrease.1.6.0

当我尝试使用 NuGet 包对话框升级这些包或更新 Newtonsoft.json 的 project.json 文件中的版本号时,出现错误。

1) Severity Code Description Project File Line Error Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL)) 0

2) Severity Code Description Project File Line Error NuGet Package Restore failed for one or more packages. See details in the Output window. Mvc6ProjectName C:[PATH TO MY FOLDER]\Source\Mvc6ProjectName\project.json 0

3) Severity Code Description Project File Line Error Dependency Newtonsoft.Json >= 6.0.8 could not be resolved Mvc6Boilerplate C:\Git\ASP.NET-MVC-Boilerplate\Source\MVC6\Mvc6Boilerplate\project.json 19

我还有一个 MVC 项目并且正在那里使用最新的 NuGet 包,那么为什么我不能升级这些包?这是因为没有更多的 web.config 文件可以指定运行时 assemblyBinding 的事实吗:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
      <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

更新 1

当我尝试从包管理器控制台更新 Newtonsoft.Json 时,出现以下错误:

PM> Update-Package Newtonsoft.Json -ProjectName Mvc6Boilerplate -Version 6.0.8 Package with the Id 'Newtonsoft.Json' is not installed to project 'Mvc6Boilerplate'.

似乎 Newtonsoft.Json 没有安装在默认的 MVC 6 项目中,而是作为另一个项目的依赖项安装的。这个 NuGet 包实际上也没有显示在 Nuget 包管理器中,而是显示在 project.json 文件中以及 References->DNX 和 DNX Core TreeView 项下。

当我尝试显式安装 Newtonsoft.Json 包时,它确实升级到 6.0.8,但随后出现上面列出的错误。

最佳答案

这个错误: “严重性代码描述项目文件行错误 NuGet 包还原一个或多个包失败。请参阅输出窗口中的详细信息。”

...通过确保我以管理员身份运行 VisualStudio 为我解决了这个问题。

尽管如此,该页面在第一次构建时并未完全呈现。

关于c# - 在 ASP.NET MVC 6 中更新 NuGet 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30323258/

相关文章:

c# - 使用委托(delegate)在表单之间进行通信

c# - 将流 pdf 传递给 asp.net 上的 HttpHandler 的最佳方法?

javascript - 如何在数据添加到数据库后立即将数据发送到网页

javascript - ajax 多次追加到同一个 div

asp.net-mvc - 跨 mvc 应用程序传递 azure token

c# - 可移植类库和 WebRequest.ContentLength

c# - 在 C# 中使用 p12 证书从 SFTP 下载文件

c# - 如何在 ASP.NET MVC Controller 中使用可选参数

asp.net - 使用 RabbitMQ 或 SignalR 的微服务架构

c# - .net mvc select list handle on selected item event