Home > Net >  System.Text.Json packages adds System.ValueTuple package even though it shouldnt need it
System.Text.Json packages adds System.ValueTuple package even though it shouldnt need it

Time:10-14

So this is pretty easy to reproduce. Create a .Net Framework 4.7.2 project and add System.Text.Json nuget package (v 5.0.2), see that it says it's going to add dependent packages including System.ValueTuple.

List of dependencies when installing System.Text.Json

But from what I understand it shouldn't.

.Net Framework 4.7.2 is .Net Standard 2.0 (see here Dependencies listed on Nuget.org for System.Text.Json

but it is for framework 4.6.1

So here is the big question... why is nuget resolving the dependencies for 4.6.1 when my project targets 4.7.2 which is .Net Standard 2.0??

CodePudding user response:

As discussed in the comments, according to this GitHub issue: "If a library is netstandard only, net472 will pick that. If a library has any net framework targets, net472 will pick that instead."

So this is the expected, if not particularly obvious, behaviour.

Fortunately, the System.ValueTuple NuGet package has a separate target for .NET 4.7 which forwards the types to the BCL implementation, so the extra reference shouldn't cause any problems.

  • Related