locked
Number of packages just exploded with latest NewtonSoft.Json package update RRS feed

  • Question

  • User35208 posted

    This doesn't seem like a good thing. I usually only see the packages I have explicitly added under "Packages".

    What's the scoop with this?

    Monday, March 20, 2017 6:52 PM

All replies

  • User21936 posted

    @TedRogers

    This is a function of the dependencies that Json.NET requires. The update obviously requires more dependencies that it did before. Looking at the package manager GUI in Xamarin Studio for Json.NET version 9.0.1, you see there are no dependencies:

    and that there are a lot for version 10.0.1:

    I usually only see the packages I have explicitly added under "Packages".

    Then you have not usually added packages that have dependencies. Many Nuget packages have dependencies, and those dependencies are installed automatically when you install the main package.

    So if you feel these dependencies are unnecessary, bring that up on the repo for Json.NET. However I suspect the dependencies are required to support the .NET Standard profile. The Nuget package manager senses what project type you are adding the package to and adjusts dependencies accordingly. You will note that if you install the Json.NET version 10.0.1 package into a pure .NET (or Mono / .NET 4.5) console project, then there are no dependencies. You can see this as well on the Nuget page for Json.NET:

    https://www.nuget.org/packages/Newtonsoft.Json

    Monday, March 20, 2017 11:57 PM
  • User35208 posted

    @JGoldberger Thanks. I decided to rollback to 9.01 for now. I had to remove each of those dependent packages one by one as they were not removed when Json.Net was removed. Makes package management quite difficult. Pretty much all of these packages are normal stuff that is part of .NET so seems strange to have them handled that way.

    I understand this is not a Xamarin issue but Json.Net is a very popular library and these changes make it very difficult to manage in Xamarin Studio.

    Tuesday, March 21, 2017 11:13 AM
  • User35208 posted

    @JGoldberger I posted the issue to the Json.Net repo. https://github.com/JamesNK/Newtonsoft.Json/issues/1252#issuecomment-288943725

    The last response to that issue conflicted with what you had stated and what we both saw in the Package Manager.

    "Well 9.0.1 depended on a similar list of packages - https://www.nuget.org/packages/Newtonsoft.Json/9.0.1

    As far as I'm concerned Json.NET isn't doing anything wrong."

    Friday, March 24, 2017 11:05 AM
  • User35208 posted

    @JGoldberger

    Latest comment from GitHub is this:

    "Perhaps it used to be binding to the PCL .NET 4.0 dll but that's been now removed so it's using the .NET Standard dll instead which carries all of those dependencies."

    Does this help understand what is going on?

    Is there a project setting I can change to use PCL .NET 4.5 which doesn't seem to have the dependencies?

    From Nuget for Json.Net: .NETFramework 4.5 No dependencies.

    Friday, March 24, 2017 1:47 PM
  • User18049 posted

    Which assembly is picked is based on what NuGet considers most compatible.

    So with Json.NET being installed into a Xamarin.iOS project NuGet picks the portable-net45+wp80+win8+wpa81 assembly.

     <Reference Include="Newtonsoft.Json">
      <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
    </Reference>
    

    This should map to the dependency group <group targetFramework=".NETPortable4.5-Profile259" /> which has no NuGet package dependencies so only Newtonsoft.Json gets added to the packages.config file.

    With Json.NET 10.0.1 NuGet now decides that the NETStandard 1.3 assembly is most compatible and references that:

    <Reference Include="Newtonsoft.Json">
      <HintPath>..\packages\Newtonsoft.Json.10.0.1\lib\netstandard1.3\Newtonsoft.Json.dll</HintPath>
    </Reference>
    

    The .NETStandard 1.3 dependency group depends on many other NuGet packages so the packages.config file gets filled with many NuGet packages.

    It looks to me as though adding the .NETStandard 1.3 assembly to the Json.NET NuGet package is the underlying cause. As to why NuGet considers that more compatible I would have to look at the NuGet source code.

    "Perhaps it used to be binding to the PCL .NET 4.0 dll but that's been now removed so it's using the .NET Standard dll instead which carries all of those dependencies." - this does not seem correct to me. The PCL .NET 4.0 dll is not used when Json.NET 9.0.1 is installed into a Xamarin.iOS project. The PCL .NET 4.5 dll is being used.

    Is there a project setting I can change to use PCL .NET 4.5 which doesn't seem to have the dependencies? - No there is no project setting. NuGet decides on the compatibility. Xamarin Studio or Visual Studio do not have a way to change the behaviour.

    Friday, March 24, 2017 4:38 PM
  • User35208 posted

    Here is the latest from @JamesNK at Json.Net:

    https://github.com/JamesNK/Newtonsoft.Json/issues/1252#issuecomment-291021380

    Monday, April 3, 2017 11:18 AM
  • User15741 posted

    @mattward Might I suggest that Xamarin gets on the phone to Newtonsoft and sorts this out ASAP?

    If the most popular package (over 50M downloads) causes the unnecessary addition of 30 package references, the simplicity of Xamarin as a solution is harmed and the maintenance burden goes up significantly. A little support time now will save a great deal of support time in the future.

    Friday, April 7, 2017 9:30 AM
  • User1683 posted

    This is how netstandard packaging works.

    Maintainability gets better in VS2017 / VS for Mac with the new Microsoft.SDK project formats, where adding a package reference doesn't actually add the transitive dependencies to the project file and instead resolves them automatically during build.

    It is actually a positive step forward because it means that Microsoft can ship framework updates through NuGet if they want (and they already are for some packages - others just defer to the one installed on the platform).

    Sunday, April 9, 2017 6:26 AM
  • User226991 posted

    I was wondering the same issue with 10.0.2 update, I guess I'm going to use the old version for now, thanks.

    Tuesday, April 18, 2017 12:41 PM
  • User263383 posted

    Besides the number of the dlls, what's the other headache? I tested, my app just runs.

    .Net Standard is the future, we will embrace it eventually.

    Friday, June 30, 2017 4:43 PM
  • User237535 posted

    @Felix.x said: Besides the number of the dlls, what's the other headache? I tested, my app just runs.

    .Net Standard is the future, we will embrace it eventually.

    So you have added all those DLLs and everything works?

    Sunday, July 2, 2017 7:05 AM