Bug 59600 - Can't resolve conflict between Microsoft.CSharp and
Summary: Can't resolve conflict between Microsoft.CSharp and
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: 7.4 (15.3)
Hardware: PC Windows
: --- normal
Target Milestone: 15.6
Assignee: dean.ellis
Depends on:
Reported: 2017-09-20 12:29 UTC by Miha Markic
Modified: 2017-10-03 20:46 UTC (History)
2 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:

sample app demonstrating the issue (8.76 KB, application/x-rar)
2017-09-20 12:29 UTC, Miha Markic

Description Miha Markic 2017-09-20 12:29:37 UTC
Created attachment 24828 [details]
sample app demonstrating the issue

Hi guys,

Using an Android app which references a .netstandard 2.0 library I'm facing the conflict below.
Obviously MonoAndroid is referencing older (or tweaked CSharp) with different version.
Since I can't just get rid of MonoAndroid assembly, how can I resolve it?

here was a conflict between "Microsoft.CSharp, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.CSharp, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
2>      "Microsoft.CSharp, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "Microsoft.CSharp, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
2>      References which depend on "Microsoft.CSharp, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll].
2>          C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll
2>            Project file item includes which caused reference "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Microsoft.CSharp.dll".
2>              Microsoft.CSharp
2>      References which depend on "Microsoft.CSharp, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
2>          C:\Users\miha\documents\visual studio 2017\Projects\App1\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll
2>            Project file item includes which caused reference "C:\Users\miha\documents\visual studio 2017\Projects\App1\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll".
2>              Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): 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.

My info.
Microsoft Visual Studio Enterprise 2017 
Version 15.3.5
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools   00369-90200-01701-AA812
Microsoft Architecture Diagrams and Analysis Tools

Visual Basic 2017   00369-90200-01701-AA812
Microsoft Visual Basic 2017

Visual C# 2017   00369-90200-01701-AA812
Microsoft Visual C# 2017

Visual C++ 2017   00369-90200-01701-AA812
Microsoft Visual C++ 2017

Application Insights Tools for Visual Studio Package   8.8.00712.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30726.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Template Engine 2017   15.0.30726.0
ASP.NET Template Engine 2017

ASP.NET Web Frameworks and Tools 2017   5.2.50601.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30728.0
Azure App Service Tools v3.0.0

Cake for Visual Studio
Adds support for the Cake build tool in Visual Studio 2015 and 2017. Includes support for the Task Runner Explorer, new templates and bootstrapping important Cake files.

CodeRush for Roslyn
DevExpress CodeRush for Roslyn package.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

CreateLayoutWizard   1.0
Create layout wizard.

DevExpress.DeploymentTool   1.0
A useful tool for deploying DevExpress assemblies.

DevExpress.Win.LayoutAssistant Extension   1.0
DevExpress.Win.LayoutAssistant Visual Studio Extension Detailed Info

A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

Markdown Editor   1.11.214
A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.6.8-pre (ec7034f)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.3.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Project File Tools   1.0.1
Provides Intellisense and other tooling for XML based project files such as .csproj and .vbproj files.

SlowCheetah - XML config transforms   1.0
This package enables you to transform your app.config or any other XML file based on the build configuration. It also adds additional tooling to help you create XML transforms.

SQL Server Data Tools   15.1.61707.200
Microsoft SQL Server Data Tools

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

TypeScript tools for Visual Studio

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Universal Windows Apps   15.0.26730.08
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

WiX Toolset Visual Studio Extension
WiX Toolset Visual Studio Extension version
Copyright (c) .NET Foundation and contributors. All rights reserved.

Xamarin (bd7e3753c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK (fb018c5)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK (152b654)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

XtraReports package   1.0
XtraReports package
Comment 1 Miha Markic 2017-09-20 12:31:20 UTC
BTW, Json.Net nuget package triggers it, but I guess it can be any library.
Comment 2 Jon Douglas [MSFT] 2017-10-03 20:46:19 UTC
I can CONFIRM this issue and I believe both https://github.com/Microsoft/msbuild/issues/1712 and https://github.com/Microsoft/msbuild/issues/608 are currently discussions for how to better relay this to developers so they can fix it.

So really I believe this happens because there is an explicit reference to Microsoft.CSharp in the Xamarin.Android project when there is a reference to Microsoft.CSharp in the netstandard library project from a library like JSON.NET.

Playing around with your sample, can you try to remove the explicit reference to the Microsoft.CSharp item and then reinstall your Newtonsoft.Json/other library item so it will properly install the Microsoft.CSharp 4.3+ version? My question however is: Overriding this assembly that we distribute could end up breaking something else as the version is from Mono and the 4.3+ version is from corefx. Given that mono is using corefx now, I think this should be okay. I am leaving this bug as CONFIRMED until someone else can take a gander at this.

Note You need to log in before you can comment on or make changes to this bug.