Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Xml.ReaderWriter 4.3.0 not compatible with .NET Framework 4.6? #19496

Closed
michael-x opened this issue Nov 28, 2016 · 19 comments
Closed

System.Xml.ReaderWriter 4.3.0 not compatible with .NET Framework 4.6? #19496

michael-x opened this issue Nov 28, 2016 · 19 comments

Comments

@michael-x
Copy link

When updating our .NET Framework 4.6 projects to NuGet package System.Xml.ReaderWriter 4.3.0 it works on some machines, but fails to build on others with an error:

CS1703: Multiple assemblies with equivalent identity have been imported: '...MySolution\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\Facades\System.Xml.ReaderWriter.dll'. Remove one of the duplicate references.

Downgrading System.Xml.ReaderWriter to 4.0.11 everything works fine on all machines.

Working machines are running VS2015, the other machine has got a .NET Framework 4.6.2 SDK installed.

@karelz
Copy link
Member

karelz commented Nov 28, 2016

Let's try to rule out misconfiguration of your project -- can you try to repro on HelloWolrd app?

@michael-x
Copy link
Author

Installing System.Xml.ReaderWriter 4.3.0 and System.Text.Encoding.CodePages 4.3.0 together in a .NET Framework 4.6 project doesn't work on some machines with only the SDK installed.

Downgrading System.Text.Encoding.CodePages does not work.
Downgrading System.Xml.ReaderWriter to 4.0.11 works.
Changing the target framework to 4.5 doesn't work because System.Text.Encoding.CodePages doesn't support it.

This is how I've tested:

  • I've created a new .NET 4.6 library project, added only System.Xml.ReaderWriter 4.3.0 and it built.
  • Then I've added Microsoft.CodeAnalysis 1.3.2 with all its dependencies and it failed.
  • Then I've updated everything to latest and it still failed.
  • Then I've removed all Microsoft.CodeAnalysis.* packages and it still failed.
  • Then I've removed Microsoft.Composition 1.0.30, System.Reflection.Metadata 1.4.1 and System.Collections.Immutable 1.3.0 and it still failed. All remaining packages have version 4.3.0.
  • Then I've started to remove System.* packages in (almost) alphabetical order. It started to build when I uninstalled System.Text.Encoding.CodePages 4.3.0.
  • I've reinstalled System.Text.Encoding.CodePages 4.3.0 and it failed again.
  • So I've skipped System.Text.Encoding.CodePages 4.3.0 and removed the remaining System.* packages except the System.Xml.* packages and it still failed.
  • Then I've removed the System.Xml.* packages except System.Xml.ReaderWriter and it failed with only System.Xml.ReaderWriter 4.3.0 and System.Text.Encoding.CodePages 4.3.0 installed.

@michael-x
Copy link
Author

Another test I did:

Setting the target framework version to 4.5 on the empty project and then adding System.Xml.ReadWriter 4.3.0 adds a reference to the System.Xml reference assembly. Then switching the target framework to 4.6 and installing System.Text.Encoding.CodePages 4.3.0 adds a reference to the packaged assembly and builds (with a warning in VS2015 about a NuGet package targeting the wrong framework version, but no warning from MSBuild on the other machine).

Then doing a

PM> Update-Package -Reinstall

the build breaks again (with or without the reference to the System.Xml reference assembly).

@michael-x
Copy link
Author

@karelz, any thoughts?

@karelz
Copy link
Member

karelz commented Dec 9, 2016

@sepidehms @krwq can you please help here?

@michael-x your repro description is a bit confusing for me. It would be best to pick the simplest one (new project) and just describe steps "1-5" how to get into the bad state. Mentioning that 4.6.2 SDK is the only difference between machines where it does/does not work (assuming I understood it correctly).

@michael-x
Copy link
Author

A simpler set of steps to reproduce:

  1. On machine A: Create a new .NET 4.6 Class Library project in Visual Studio 2015
  2. On machine B: Build using MSBuild 14 --> Works
  3. On machine A: Add NuGet package System.Text.Encoding.CodePages 4.3.0
  4. On machine B: Build using MSBuild 14 --> Works
  5. On machine A: Add NuGet package System.Xml.ReaderWriter 4.3.0
  6. On machine B: Build using MSBuild 14 --> Error

CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'D:\Source\Test\ClassLibrary2\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\Facades\System.Xml.ReaderWriter.dll'. Remove one of the duplicate references.

Machine A has got Visual Studio 2015 installed, machine B has got the .NET Framework 4.6.2 SDK installed, no Visual Studio (build machine).

@krwq
Copy link
Member

krwq commented Dec 9, 2016

@michael-x do you also get build errors on Machine A on Step 5?
@ericstj I'm wondering if you know about some issues similar to this? Is it possible that 4.6.2 SDK is in some way different?

@michael-x
Copy link
Author

@krwq no, I don't get any build errors on machine A.

I've noticed that System.Text.Encoding.CodePages.dll seems to be portable and that there is a folder

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable

on machine A, but not on machine B. Could that be related? (I've tried installing "Microsoft .NET Portable Library Reference Assemblies 4.6" on machine B, but that didn't help.)

@fabiano
Copy link

fabiano commented Dec 13, 2016

I was having the same problem with the same package. Building on my machine (VS 2015 Update 3) but failing on my build server (Build Tools 2015).

Fixed when I updated my build server to use the Build Tools 2015 Update 3.

@michael-x
Copy link
Author

@fabiano I just installed Microsoft Build Tools 2015 Update 3 and it looks like it did the trick. Thanks for your help!

@FikoGH
Copy link

FikoGH commented Dec 30, 2016

The solution provided by @fabiano is working.

Thank you @fabiano!

@ericstj
Copy link
Member

ericstj commented Dec 30, 2016

If you'd like a smaller fix you can just update the NuGet extension. Our packages depend on NuGet 3.4.3 or later, but unfortunately we cannot pre-req that version in the packages, because we also need them to work in VS2013 where we need NuGet 2.12 or later.

This is a side-effect of NuGet not updating older VS versions with NuGet 3, but instead simultaneously updating NuGet 2.x and NuGet 3.x without providing a way for us to independent pre-req them.

@michael-x
Copy link
Author

@ericstj if you are referring to the NuGet extension for Visual Studio, then you are missing the point: it's the build on the machine that does not have Visual Studio installed that fails. Updating MSBuild Tools 2015 to Update 3 works for whatever magical reason. (I guess the key sentence in the release notes is "We've improved support for Portable class libraries targeting the .NET Platform Standard", but I'm not sure about that.)

@ericstj
Copy link
Member

ericstj commented Dec 30, 2016

I see, indeed I did miss the point. That does make sense. I believe a fix in Roslyn removed this check, but it would have been in for a long time. Perhaps Update 3 caused you to start using csc from buildtools (roslyn) instead of the old native csc (fx directory). The root issue still exists, MSBuild adds facades that are already provided by NuGet packages. This is being tracked with dotnet/msbuild#1345.

@michael-x
Copy link
Author

I would have thought that we are already using Roslyn since we are using compiler features like Interpolated Strings and Null-conditional Operators which to my knowledge are only implemented in Roslyn. Whether the issue that you've mentioned applies here I cannot tell.

russcam referenced this issue in elastic/elasticsearch-net Jan 12, 2017
This is to work around

C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property
to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190. [C:\Users\russ\s ource\elasticsearch-net-2.x\src\Profiling\Profiling.csproj]

and

CS1703: CSC(0,0): Multiple assemblies with equivalent identity have been imported: 'T:\TeamCity\buildAgent\work\3bd1c67a330a3167\packages\System.Xml.ReaderWriter\lib\net46\System.Xml.ReaderWriter.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\Facades\System.Xml.ReaderWriter.dll'. Remove one of the duplicate references.

on CI Server. Looks to be related to https://github.com/dotnet/corefx/issues/14050, although the recommendation to install Microsoft Build Tools 2015 Update 3 (https://www.visualstudio.com/downloads/#microsoft-build-tools-2015-update-3) did not fix the problem locally.
@jt000
Copy link

jt000 commented Feb 26, 2017

I was seeing this issue also in projects that weren't using the Microsoft.CodeDom.Providers.DotNetCompilerPlatform in Azure (i.e. class libraries & console apps). By adding this package to these projects, the props\targets were updated and this issue was resolved. Note that this issue existed in Microsoft.Net.Compilers v1.0.0, so you'll need to latest (currently v1.3.2) if you see this issue & you have these packages in your project.

See projectkudu/kudu#2336 for more info

@Jorgelig
Copy link

Jorgelig commented Sep 21, 2017

@jsgoupil
Copy link

What is the recommendation to make this work on Azure. Everything works fine on my computer but on Azure, it gives me this error.

@owlyowl
Copy link

owlyowl commented Nov 9, 2017

I'm getting the Multiple Assemblies with Equivalent Identity

System.Xml.ReaderWriter is included as part of NetStandard.Library's nuget package and another package requires a nuget reference to System.Xml.ReaderWriter assembly version 4.3.0.

This blows up the build (I'm trying to deploy from github) with:

CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'D:\home\site\repository\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll' and 'D:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\Facades\System.Xml.ReaderWriter.dll'. Remove one of the duplicate references. [D:\home\site\repository\xxxxxxxxxx.Web\xxxxxxxxxxx.Web.csproj]

Has there many any resolution on this?? works fine locally and on other hosting but blows up on Azure..

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests