When assembling, I get a series of errors like this:

CSC: error CS1703: Imported several assemblies with the same identity: 'C: \ Program Files (x86) \ MSBuild \ Microsoft \ Microsoft.NET.Build.Extensions \ net461 \ ref \ System.Collections.Concurrent.dll "and" C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.6.1 \ Facades \ System.Collections.Concurrent.dll. Remove one of the duplicate links.

An error occurred when I tried to add the System.Threading.Tasks.Dataflow package. Reproduced on an empty project: create a console application, add a package - and that's not going to.

Used by Visual Studio 2015.

    1 answer 1

    This error is caused by a conflict of support mechanisms for the Portable Class Library and the .NET Standard.

    The first is in MSBuild\14.0\Bin\Microsoft.NetFramework.CurrentVersion.targets , the second is in MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.NETFramework.targets . They do the same thing - they add references to "virtual" platform-independent assemblies to the project so that the compiler does not worry about their absence. And since they do the same thing, they add the same links to the assemblies.

    In this case, references to PCL are always added, and references to .NET Standard - only in the presence of such dependencies.

    If your project does not have references to PCL libraries, then the correct solution would be to write the following key in the project file:

     <ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades> 

    This will disable the first mechanism and it will work.

    If in the project such dependences are present - then the following error may appear at compile time:

    error CS0012: The type 'System.ComponentModel.DataAnnotations.ValidationResult' is defined by an assembly that is not referenced. You can add a reference to assembly 'System.ComponentModel.DataAnnotations, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a'.

    Similar issues are possible with the following builds (they are included in PCL, but not included in .NET Standard):

    • System.ComponentModel.Annotations.dll
    • System.Reflection.Emit.dll
    • System.Reflection.Emit.ILGeneration.dll
    • System.Reflection.Emit.Lightweight.dll
    • System.Runtime.InteropServices.WindowsRuntime.dll
    • System.ServiceModel.Duplex.dll
    • System.ServiceModel.Http.dll
    • System.ServiceModel.NetTcp.dll
    • System.ServiceModel.Primitives.dll
    • System.ServiceModel.Security.dll

    In this case, instead of solving above, you can try to create a Target like this:

     <Target Name="ResolvePCLAndNETStandardConflicts" DependsOnTargets="ImplicitlyExpandDesignTimeFacades;ImplicitlyExpandNETStandardFacades" BeforeTargets="ResolveAssemblyReferences"> <ItemGroup> <ResolvePCLAndNETStandardConflicts_ReferencePathToExclude Include="@(DesignTimeFacadeDirectories)"> <RelativeName>%(_NETStandardLibraryNETFrameworkReference.Filename).dll</RelativeName> </ResolvePCLAndNETStandardConflicts_ReferencePathToExclude> <ReferencePath Remove="@(ResolvePCLAndNETStandardConflicts_ReferencePathToExclude->'%(Identity)%(RelativeName)')" /> </ItemGroup> </Target>