简体   繁体   中英

Updating NuGet packages in ASP.NET MVC 6

I just created a new ASP.NET MVC 6 project and wanted to update the NuGet packages to their latest versions (The default project templates are usually very out of date). I noticed the following updates were possible:

  • 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

When I try to upgrade these packages wither using the NuGet package dialog or updating the version numbers in the project.json file for Newtonsoft.json, I get errors.

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

I also have a MVC project and am using the latest NuGet packages there so why can't I upgrade these packages? Is this to do with the fact that there is no more web.config file where we can specify runtime assemblyBinding's:

<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>

Update 1

When I try to update Newtonsoft.Json from the package manager console, I get the error below:

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

It seems that Newtonsoft.Json is not installed in the default MVC 6 project but is installed as a dependency of another project. This NuGet package is not actually displayed in the Nuget Package Manager either but is displayed in the project.json file and also under the References->DNX and DNX Core tree view item.

When I try to explicitly install the Newtonsoft.Json package, it does upgrade to 6.0.8 but I then get the errors I listed above.

This error: "Severity Code Description Project File Line Error NuGet Package Restore failed for one or more packages. See details in the Output window."

...was resolved for me by ensuring I was running VisualStudio as an Administrator.

Although, the page did not fully render well on the first build.

我现在知道的最简单的解决方案是使用Visual Studio 2013而不是2015来升级您的软件包。

It seems that the problem has been resolved. You have to update your NugetPackage Manager:

Tools > Extensions and Updates > Updates > Visual Studio Gallery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM