0
votes

The solution builds fine in Visual Studio 2017.

MSBuild will produce the following warning:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets (2106, 5): warning MSB3277: 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.

A couple line will show up after the warning, but from there it halts and doesn't progress at all.

The actual reference conflict is here:

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:123) 4> "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:123) 4> 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\MonoAndroid\v1.0\Microsoft.CSharp.dll]. (TaskId:123) 4> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll (TaskId:123) 4> Project file item includes which caused reference "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll". (TaskId:123) 4> Microsoft.CSharp (TaskId:123) 4> References which depend on "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" []. (TaskId:123) 4> C:\Users\laniganr.nuget\packages\newtonsoft.json\10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll (TaskId:123)

A couple other lines will show up right after the error, but never progresses past this point.

Said lines:

_XamarinAndroidBuildAarRestore: Reference has already had resources merged, skipping due to: obj\ReleaseNuget\XbdMerge\Xamarin.GooglePlayServices.Bas ement.dll.stamp Reference has already had resources merged, skipping due to: obj\ReleaseNuget\XbdMerge\Xamarin.GooglePlayServices.Tas ks.dll.stamp Reference has already had resources merged, skipping due to: obj\ReleaseNuget\XbdMerge\Xamarin.Firebase.Common.dll.st amp Reference has already had resources merged, skipping due to: obj\ReleaseNuget\XbdMerge\Xamarin.Firebase.Iid.dll.stamp Reference has already had resources merged, skipping due to: obj\ReleaseNuget\XbdMerge\Xamarin.Firebase.Messaging.dll .stamp _ResolveLibraryProjectImports: Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files . _BuildLibraryImportsCache: Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.

1
Any update for this issue? Have you resolved this issue? If not, would you please let me know the latest information about this issue?Leo Liu-MSFT

1 Answers

1
votes

Visual Studio Android solution stops building upon hitting C# version conflict when using MSBuild

That because there is an explicit reference to Microsoft.CSharp 2.0.5.0 in the Xamarin.Android project when there is a reference to Microsoft.CSharp 4.3.0.0 in the netstandard library project from a library newtonsoft.json 10.0.3.

In the build log, you can find your project referencing the package newtonsoft.json in following message:

C:\Users\xxxxx\packages\newtonsoft.json\10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll (TaskId:123)

Then check the dependence of the package newtonsoft.json\10.0.3\lib\netstandard1.3:

enter image description here

To resolve this issue, you can try to update Newtonsoft.Json to the version 11.0.1 and above. This is because this version of Newtonsoft.Json package for netstandard 2.0 has no dependency to Microsoft.CSharp.

Alternatively, you can remove the Microsoft.CSharp 2.0.5 and allow the one from Nuget to be used.

You can refer to the similar thread here and here for some more details.

Hope this helps.