Found conflicts between different versions of the

2020-03-01 06:26发布

问题:

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 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?

回答1:

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.



回答2:

I fixed it by updating Newtonsoft.Json package.



回答3:

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.



回答4:

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.



回答5:

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.



回答6:

Probably a little late to answer this but this happens because 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.