简体   繁体   English

在ASP.NET MVC 6中更新NuGet包

[英]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). 我刚刚创建了一个新的ASP.NET MVC 6项目,并希望将NuGet包更新到最新版本(默认项目模板通常非常过时)。 I noticed the following updates were possible: 我注意到以下更新是可能的:

  • Antlr.3.4.1.9004 > Antlr.3.5.0.2 Antlr.3.4.1.9004> Antlr.3.5.0.2
  • Newtonsoft.Json.6.0.4 > Newtonsoft.Json.6.0.8 Newtonsoft.Json.6.0.4> Newtonsoft.Json.6.0.8
  • WebGrease.1.5.2 > WebGrease.1.6.0 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. 当我尝试使用NuGet包对话框升级这些软件包或更新newtonsoft.json的project.json文件中的版本号时,我收到错误。

1) Severity Code Description Project File Line Error Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL)) 0 1)严重性代码描述项目文件行错误未实现(HRESULT异常:0x80004001(E_NOTIMPL))0

2) Severity Code Description Project File Line Error NuGet Package Restore failed for one or more packages. 2)严重性代码描述项目文件行错误NuGet包恢复一个或多个包失败。 See details in the Output window. 在“输出”窗口中查看详细信息 Mvc6ProjectName C:[PATH TO MY FOLDER]\\Source\\Mvc6ProjectName\\project.json 0 Mvc6ProjectName C:[路径到我的文件夹] \\ 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 3)严重级代码描述项目文件行错误依赖项Newtonsoft.Json> = 6.0.8无法解析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? 我也有一个MVC项目,我在那里使用最新的NuGet包,为什么我不能升级这些包呢? Is this to do with the fact that there is no more web.config file where we can specify runtime assemblyBinding's: 这是否与没有更多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>

Update 1 更新1

When I try to update Newtonsoft.Json from the package manager console, I get the error below: 当我尝试从包管理器控制台更新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'. PM> Update-Package Newtonsoft.Json -ProjectName Mvc6Boilerplate -Version 6.0.8包含Id'Newtoftoft.Json'的包未安装到项目'Mvc6Boilerplate'。

It seems that Newtonsoft.Json is not installed in the default MVC 6 project but is installed as a dependency of another project. 似乎Newtonsoft.Json没有安装在默认的MVC 6项目中,而是作为另一个项目的依赖项安装。 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. 此NuGet包实际上并未显示在Nuget包管理器中,但显示在project.json文件中,也显示在References-> DNX和DNX Core树视图项下。

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. 当我尝试显式安装Newtonsoft.Json包时,它确实升级到6.0.8但我得到了上面列出的错误。

This error: "Severity Code Description Project File Line Error NuGet Package Restore failed for one or more packages. See details in the Output window." 此错误:“严重性代码说明项目文件行错误NuGet包还原失败,一个或多个包。请参阅”输出“窗口中的详细信息。

...was resolved for me by ensuring I was running VisualStudio as an Administrator. ...通过确保我以管理员身份运行VisualStudio来解决这个问题。

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: 您必须更新您的NugetPackage Manager:

Tools > Extensions and Updates > Updates > Visual Studio Gallery 工具>扩展和更新>更新> Visual Studio库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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