I have a Blazor library that depends on another Blazor library. When I try to build the libraries I get a conflict with System.text.json. When I turn on verbose msbuild info I found this:
Dependency "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
4> Could not resolve this reference. Could not locate the assembly "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
4> Required by "C:\Users\cbraunstein\source\Personal\BlazorPrettyCode\src\BlazorPrettyCode\bin\Release\netstandard2.0\BlazorPrettyCode.dll".
4> Required by "C:\Users\cbraunstein\source\Personal\BlazorPrettyCode\src\SamplePages\bin\Release\netstandard2.1\SamplePages.dll".
4> There was a conflict between "System.Text.Json, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
4> "System.Text.Json, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was chosen because it was primary and "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was not.
4> References which depend on "System.Text.Json, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Text.Json.dll].
4> C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Text.Json.dll
4> Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Text.Json.dll".
4> C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Text.Json.dll
4> References which depend on "System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [].
4> C:\Users\cbraunstein\source\Personal\BlazorPrettyCode\src\BlazorPrettyCode\bin\Release\netstandard2.0\BlazorPrettyCode.dll
4> Project file item includes which caused reference "C:\Users\cbraunstein\source\Personal\BlazorPrettyCode\src\BlazorPrettyCode\bin\Release\netstandard2.0\BlazorPrettyCode.dll".
4> C:\Users\cbraunstein\source\Personal\BlazorPrettyCode\src\BlazorPrettyCode\bin\Release\netstandard2.0\BlazorPrettyCode.dll
4> C:\Users\cbraunstein\source\Personal\BlazorPrettyCode\src\SamplePages\bin\Release\netstandard2.1\SamplePages.dll
4> C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "System.Text.Json" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
I am unclear where the different versions are coming from or how to fix it.
@chanan thanks for contacting us.
Can you provide a minimal repro so that we can investigate try to determine what's going on here?
This will be ultimately fixed in 5.0 for free since there will only be one STJ version.
@pranavkm do you have any thoughts?
Hi @javiercn
Since I dont know the exact cause I can't create a small repro, but I do have a larger one here: https://github.com/chanan/BlazorPrettyCode - you should see the issue if you compile that solution and/or you might need to try to run either the client-side or server-side samples.
One more point about this. This also happened with Microsoft.Extensions.ObjectPool - but in that case I reverted its usage and went back to creating StringBuilders "by hand". If needed I can put that code back if you want to see that issue as well.
Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we will planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
Hey guys, I know this might be top pripority because it doesnt happen to many people (although I see Blazored is now running into this too), but this really is a critical blocker where I can't compile Blazor projects due to this.
It would be great to get some guidance on how to deal with this in the short term, until .NET5 is available.
A suggestion put forward in Blazored LocalStorage (https://github.com/Blazored/LocalStorage/issues/95#issuecomment-654384731) was to change the target framework from netstandard2.1 to netcoreapp3.1. This resolves the issue, however, I'm not sure what the impact of this change would be.
I am having the same issue with an MVC API and class library. The conflict seems to be caused by nuget package Microsoft.Extensions.Configuration.Json v3.1.6 in the class library.
C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0ref\netcoreapp3.1 is 4.0.1.0 while the file C:\Users\Bob.nuget\packages\microsoft.extensions.configuration.json\3.1.6\microsoft.extensions.configuration.json.nuspec references version 4.7.2 (version=4.0.1.2 in the build log).
Note: Downgrading the nuget package to v3.0.0 removed the build error and allowed the republished to function.
Hey guys, I know this might be top pripority because it doesnt happen to many people (although I see Blazored is now running into this too), but this really is a critical blocker where I can't compile Blazor projects due to this.
@chanan For your BlazorPrettyCode repo, what seems to be causing the conflict is the Microsoft.NetCore.App framework and what seems to work is making sure the ServerSideSample uses the newer System.Text.Json by specifying that in the csproj
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup>
Marking this as resolved since there's a reasonable workaround.
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.
Most helpful comment
@chanan For your BlazorPrettyCode repo, what seems to be causing the conflict is the Microsoft.NetCore.App framework and what seems to work is making sure the ServerSideSample uses the newer System.Text.Json by specifying that in the csproj