Version conflict caused by Microsoft.NET.Sdk.Functions

后端 未结 4 1109
悲&欢浪女
悲&欢浪女 2020-12-30 20:09

I\'m having issues with a project referencing 2 packages that then reference Newtonsoft.Json but both at different versions. I\'m using the nuget package of Refit

相关标签:
4条回答
  • 2020-12-30 20:53

    Running into related issue, not being able to install the Mirosoft.NET.Sdk package. Worked around this by creating a new Cloud - Azure functions project using vs2017. That project comes with the Mirosoft.NET.Sdk package version 1.0.6. Updating that to 1.0.7 actually works. Then installed Newton 9.0.1. From there on, no problems.

    0 讨论(0)
  • 2020-12-30 20:56

    In Azure the functions runtime loads a spececific (currently 11.0.1 in functions v2, 9.0.1 in functions v1) version of the Newtonsoft.Json before your function library gets loaded by the queue binding.

    Any workarounds applied to make it compile will cause horrible to diagnose runtime failures if you use any function that is not binary compatible with [11.0.1] (eg, any of the new attributes used in v12) .

    0 讨论(0)
  • 2020-12-30 20:58

    Latest Update

    The lock was removed and the version upgraded to 11.0.2 in July 2019. Upgrading to 12 can still cause some deployment issues


    Unfortunately, this is a known bug of the Azure Functions MSBuild project. All the release versions have a hard-coded dependency on Json.NET 9.0.1. The only workaround reported is to downgrade to the 1.0.0-alpha6 version.

    The lack of package summary and description, as well as the lack of documentation in the Github project are a clear sign that this is a work in progress.

    Assuming you do need it, you can try to clone the repo, change the dependency in .csproj and rebuild the package.

    In the meantime, you should probably add a comment to the issue, explaining that you are affected as well.

    To fix this, Line 39 of csproj should change from :

    <PackageReference Include="Newtonsoft.Json" Version="[9.0.1]" />
    

    to

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

    There other exact version dependencies on beta versions of Microsoft.Azure.WebJobs packages

    Update November 2018

    The repo's Readme was updated on March 31 2018 with an FAQ that explains why the Json.NET version is locked and how to handle this :

    Q: I need a different Newtonsoft.Json version. What do I do?

    A: Add the version you need to your csproj. For example to use 11.0.2 add this to your csproj

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

    Q: Why is Newtonsoft.Json locked in the first place?

    A: The version of Newtonsoft.Json is locked to match the version used by the functions runtime

    There's a long discussion on the (now locked) issue that explains that unlocking the version would only delay problems until deployment

    Update September 2019

    The Json.NET version is no longer locked and the referenced version is 11.0.2. The PR was merged in July 2019. As the comments show though, this simply removes the compile-time restriction. It's still possible to get deployment problems though, like this one

    0 讨论(0)
  • 2020-12-30 21:00

    I was able to get my project working with Netwonsoft.Json 11.0.2 by switching to v2 of Azure Functions with .net core:

      <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <AzureFunctionsVersion>v2</AzureFunctionsVersion>
      </PropertyGroup>
    
    0 讨论(0)
提交回复
热议问题