Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Text.Json version conflict

Tags:

c#

.net

I have a solution with 2 projects:

  • netcoreapp3.1 Azure Function
  • netstandard2.1 library

The netcoreapp3.1 project references the library one. The library project makes use of the System.Text.Json APIs. When I build the solution I get the following error:

Assembly 'System.Text.Json' with identity 'System.Text.Json, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' uses 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I tried explicitly installing the System.Text.Json 4.7.2 into the netstandard2.1 project. The app now compiles and works. However, during build process I get a few warnings like this:

##[warning]/usr/share/dotnet/sdk/5.0.101/Microsoft.Common.CurrentVersion.targets(2123,5): Warning MSB3243: No way to resolve conflict between "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "System.Text.Json, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". Choosing "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" arbitrarily.

What am I doing wrong?

like image 619
mnj Avatar asked Sep 01 '25 02:09

mnj


1 Answers

Here is perhaps a better answer.

Downgrade Microsoft.Extensions.Configuration.Json to 3.1.1 as in my screenshot.

Thanks to this github issue workaround.

enter image description here

like image 200
Jess Avatar answered Sep 02 '25 17:09

Jess