Skip to content

Unable to build using Newtonsoft.Json 12.0.1 #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SpencerWaz opened this issue Aug 9, 2019 · 9 comments
Open

Unable to build using Newtonsoft.Json 12.0.1 #330

SpencerWaz opened this issue Aug 9, 2019 · 9 comments
Assignees

Comments

@SpencerWaz
Copy link

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

@deyanp
Copy link

deyanp commented Sep 17, 2019

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?

@DeluxZ
Copy link

DeluxZ commented Sep 23, 2019

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

@AtOMiCNebula
Copy link

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

@simonvane
Copy link

simonvane commented Oct 1, 2019

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

@DeluxZ
Copy link

DeluxZ commented Oct 1, 2019

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

@simonvane
Copy link

@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 @DeluxZ . I don't have using Newtonsoft.Json.Serialization; anywhere in my solution.

@DigitalMystery
Copy link

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

@simonvane
Copy link

@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

@drdamour
Copy link

seems like this issue could be closed

@fabiocav fabiocav self-assigned this Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants