Skip to content

Unable to build using Newtonsoft.Json 12.0.1 #330

Open

Description

Getting the same error as in this comment: here. Since this was posted after the issue was closed, I figured I'd continue the discussion here

Function SDK: 1.0.30-beta1
Newtonsoft.Json: 12.0.1

I'm able to restore the packages after #323 but when I build the project I'm getting the same error as above.

image

Activity

  1. deyanp commented on Sep 17, 2019

    @deyanp

    Same for me, and if I reference Newtonsoft.Json 11.0.2 I get project reference issues with Jetbrains Rider/F#, see JetBrains/resharper-fsharp#61
    What is the reason for insisting on 11.0.2?

  2. DeluxZ commented on Sep 23, 2019

    @DeluxZ

    Same issue here. When referencing 12.0.2 I get two errors. One is a FileLoadException about Newtonsoft.Json which can not be found. The second one is about Metadata generation failed. When I remove 12.0.2 it's ok but I need 12.0.2 because our own package uses >=12.0.2. Worked perfectly until today.

    Note: I have updated VS2019 to the latest version last friday.

    'Fixed' it because of this comment

  3. AtOMiCNebula commented on Sep 30, 2019

    @AtOMiCNebula

    Have you read the FAQ in the README in the root of this repo? The strict version match is not there by accident.

  4. simonvane commented on Oct 1, 2019

    @simonvane

    Jeff Weiner (@AtOMiCNebula) - I have read the FAQ in the README.

    I am not using JObject so I don't need to stick to the same version as the runtime uses. The README says I can set the version I want to use in the project directly as does the build error I get:
    NU1107: Version conflict detected for Newtonsoft.Json. Install/reference Newtonsoft.Json 12.0.2 directly to project <function project> to resolve this issue.

    However, when I try to do that I get the following error and the change rolls back:
    NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 11.0.2) but version Newtonsoft.Json 12.0.2 was resolved.

    Any idea how can I resolve this issue?

  5. DeluxZ commented on Oct 1, 2019

    @DeluxZ

    Simon Vane (@simonvane) Check the link I mentioned previously. Do you have any using to NewtonSoft in a file within your function app project? That caused the issue on my side.

  6. simonvane commented on Oct 1, 2019

    @simonvane

    Simon Vane (@simonvane) Check the link I mentioned previously. Do you have any using to NewtonSoft in a file within your function app project? That caused the issue on my side.

    Thanks Harrie Essing (@DeluxZ) . I don't have using Newtonsoft.Json.Serialization; anywhere in my solution.

  7. DigitalMystery commented on Nov 27, 2019

    @DigitalMystery

    Simon Vane (@simonvane) did you ever resolve this? Running into the same thing and already checked the linked thread.

  8. simonvane commented on Dec 6, 2019

    @simonvane

    Kevin Mistry (@DigitalMystery) I am now referencing the following in my function apps:

    Solution a:

        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
        <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    

    Solution b:

        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.30-beta4" />
        <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    

    I have lost track of what I did to resolve it because I have encountered so many similar issues in recent months.

    My two suggestions are:

    1. Explicitly reference the version you want to use in all projects.
    2. If you find that when you try to upgrade the version of a nuget pack and it fails and rolls back, try the following:
      a) close the solution
      b) run dotnet clean in the solution root
      c) add the reference to the project file(s) manually in a text editor and save the changes
      d) run dotnet restore in the solution root
      e) run dotnet build --no-restore in the solution root
  9. drdamour commented on Aug 25, 2021

    @drdamour

    seems like this issue could be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions