【问题标题】:Always use latest version of Newtonsoft.Json始终使用最新版本的 Newtonsoft.Json
【发布时间】:2019-06-09 15:15:43
【问题描述】:

我有一个 .NET 项目,它引用了一个依赖于 Newtonsoft.Json 版本 6.0.8 的 nuget。 nuget 是https://www.nuget.org/packages/Microsoft.Azure.KeyVault/3.0.2

我想在我的项目中只使用最新版本的 Newtonsoft,所以我希望这个项目实际使用 12.0 版的 Newtonsoft。我不确定这是否可能。我尝试将 app.config 文件添加到我的项目中,但没有成功。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.1.0" newVersion="12.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

有什么方法可以实现吗?

【问题讨论】:

  • 你真的想要那个吗?如果他们在新版本中破坏了某些东西怎么办?
  • Floating Versions 如果使用 .NET Core 项目、.NET Standard 项目和面向 Creators Update 及更高版本的 UWP 项目中默认使用的新项目格式,则 PackageReference 元素支持:@ 987654323@
  • 如果我在 Nuget 页面上的“依赖项”下查看,我看到 Newtonsoft 的推荐版本是:Newtonsoft.Json (>= 6.0.8) 所以,11 是 >= 6.0.8,我恢复它不会破坏任何东西。

标签: c# json.net dependencies nuget-package


【解决方案1】:

我解决了这个问题,我让项目明确引用了最新版本的 Newtonsoft。一切似乎都正常。

<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-06
    • 2012-01-09
    • 2018-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多