CsvHelper icon indicating copy to clipboard operation
CsvHelper copied to clipboard

Conflict between Microsoft.CSharp 2.0.5.0 and 4.0.0 on Xamarin (Warning MSB3277)

Open jandroalvarez opened this issue 6 years ago • 6 comments

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:

  1. Create a Xamarin.iOS project
  2. Add CsvHelper v12.1.2 as dependency
  3. Compile on VS2017 with detailed verbosity on output
  4. 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.

jandroalvarez avatar May 30 '19 07:05 jandroalvarez

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.

JoshClose avatar Oct 28 '19 19:10 JoshClose

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.

Roshan-Yadav avatar Jan 06 '20 12:01 Roshan-Yadav

When we install CsvHelper in the Xamarin project, we also get the same warning. Any solution or workaround would be appreciated.

Thanks.

Lakshminatarajan avatar Nov 10 '21 05:11 Lakshminatarajan

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?

mdmota avatar Dec 13 '21 19:12 mdmota

Hello I am getting the same error, any workaround?

ivanrlg avatar Jan 06 '22 20:01 ivanrlg

I decided to convert a csv to json and reading a json without using this dependency

mdmota avatar Jan 06 '22 21:01 mdmota