Conflict between Microsoft.CSharp 2.0.5.0 and 4.0.0 on Xamarin (Warning MSB3277)
Describe the bug During the compilation of a Xamarin.iOS project, I'm getting the following error:
18> 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".
18> "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.
18> References which depend on "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Microsoft.CSharp.dll].
18> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Microsoft.CSharp.dll
18> Project file item includes which caused reference "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Microsoft.CSharp.dll".
18> Microsoft.CSharp
18> References which depend on "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll].
18> C:\Users\alex\.nuget\packages\csvhelper\12.1.2\lib\netstandard2.0\CsvHelper.dll
18> Project file item includes which caused reference "C:\Users\alex\.nuget\packages\csvhelper\12.1.2\lib\netstandard2.0\CsvHelper.dll".
18> C:\Users\alex\.nuget\packages\csvhelper\12.1.2\lib\netstandard2.0\CsvHelper.dll
To Reproduce Steps to reproduce the behavior:
- Create a Xamarin.iOS project
- Add CsvHelper v12.1.2 as dependency
- Compile on VS2017 with detailed verbosity on output
- Warning MSB3277
Expected behavior Warning MSB3277 shouldn't be detected
Additional context It seems an MSBuild issue on Xamarin as some people already stated on xamarin/xamarin-android#1261, xamarin/xamarin-android#1607.
The issue Microsoft/msbuild#3392 has been opened but there isn't any reply.
The same issue had been detected on Newtonsoft.Json v10.0.3 (see JamesNK/Newtonsoft.Json#1600) and fixed on v11.0.1. It seemed a matter of getting rid of Microsoft.CSharp NuGet package.
It looks like Newtonsoft.Json created a netstandard2.0 build and didn't need to use the Microsoft.CSharpt package anymore. I'm assuming that is because whatever feature is being used became a part of 2.0. I don't see any other way of getting the functionality without having Microsoft.CSharp included.
All the links keeps saying it's a MSBuild issue that needs to be fixed. I don't believe there is anything I can do to fix this.
I am also getting build warning: Found conflicts between different versions of "Microsoft.CSharp" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. in my project. To fix the warning, I tried updating Newtonsoft.Json to the latest version (12.0.3) and removing the references of Microsoft.CSharp from the project but no luck in fixing the warning.
When we install CsvHelper in the Xamarin project, we also get the same warning. Any solution or workaround would be appreciated.
Thanks.
I am also getting build warning: Found conflicts between different versions of "Microsoft.CSharp" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. in my project. To fix the warning, I tried updating Newtonsoft.Json to the latest version (12.0.3) and removing the references of Microsoft.CSharp from the project but no luck in fixing the warning.
removed the references of Microsoft.CSharp references from where?
Hello I am getting the same error, any workaround?
I decided to convert a csv to json and reading a json without using this dependency