23
votes

Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

It's happened after I'm import Newtonsoft.Json to my App.Core(Portable) project.

After a look in the output:

There was a conflict between "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". (TaskId:90) 2> "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not. (TaskId:90)

What I need to do now?

8
The fix for me was to look in my packages.config and make sure that all packages in their are relevant to your project. I somehow managed to remove a nuget package from my project but it still remained in the packages.config file. I think it was because I was doing some quick transactions on the nuget packages of my project and visual studio couldnt keep up with the writing to the files. Hence causing the error you've given. Just thought i'd give you the problem from another perspective. I hope this helps someone.cwiggo

8 Answers

10
votes

I fixed it by updating Newtonsoft.Json package.

9
votes

I fixed this issue by downgrading my version of Newtonsoft.Json to 8.0.3, that was the newest version that didn't cause this error on build. I am unsure as to why this was the fix however.

1
votes

I was able to fix this by adding the Microsoft.CSharp NuGet package to my project. Previously I just had a reference to the Microsoft.CSharp assembly under the project references, but I wasn't using NuGet to pull it in. After using NuGet the message on my VSTS build server went away.

1
votes

Newtonsoft.Json is relying on a newer version of the Microsoft.CSharp assembly than your project is referencing. You can remove the reference to the old library and add the newer one. The newer one may be in your packages directory for your solution, or you may be able to get the NuGet package. In my case, the only reference that depended on the old version of the CSharp library was itself, so there was no harm in doing this.

1
votes

I had this problem at my Xamarin.Forms project with Android-only solution.

The fix was easy: Linking the latest Newtonsoft.Json directly to my Android project and the shared library.

The warning emerged when I've linked some NuGet package that was relying on the old version of Newtonsoft.Json package with a different, incompatible version C#.

0
votes

The problem it's the Newtonsoft.Json NuGet, after I down his version the warning just go.

Probably a plug-in issue with Windows 10.

0
votes

If you are using Portable Libraries, there is a known problem with certain versions of the NuGet client which causes a build error in the Xamarin.iOS and Xamarin.Android projects when they have a reference to these build packages. The error message will say something similar to

warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

To resolve this issue, remove the following references from the Xamarin.iOS and Xamarin.Android platform-specific project - leave the package, just delete the references from the References folder. You should be able to build at that point.

  • System.Runtime

  • System.IO

  • System.Threading.Tasks

For more information on this error, see this MSDN blog post.

0
votes

I fixed this warning by removing the Microsoft.CSharp reference from my Android-specific csproj file. Microsoft.CSharp did not appear in the Android-specific Packages for my project in Visual Studio Solution Explorer, but the reference to CSharp was in the Android .csproj file. Specifically, I removed this line from my Android csproj file:

  <Reference Include="Microsoft.CSharp" />

At the time of the error (and fix), my environment was as follows:

  • Visual Studio Community 2019 for Mac (running in Big Sur 11.5.1)
  • Xamarin PCL project building for both iOS and Android
  • Xamarin.Forms version 5.0.0.2012
  • Newtownsoft.Json version 13.0.1