Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Package Manager: 'AutoMapper' already has a dependency defined for 'Microsoft.CSharp'

I'm trying to add AutoMapper as a dependency to a project using NuGet on Visual Studio Premium 2012, but it fails.

It says:

Operation failed
'AutoMapper' already has a dependency defined for 'Microsoft.CSharp'.

I'm able to add other dependencies.

I'm using the last version of the package manager for VS 2012:

NuGet Package Manager 2.8.60318.667

Any ideas what should I check?

like image 951
pomber Avatar asked Jul 07 '16 14:07

pomber


1 Answers

The problem is that your NuGet Package Manager is too old. You need NuGet 2.12 since this supports the newer .NETStandard frameworks that the AutoMapper 5.0.1 NuGet package is using.

The AutoMapper has a group dependency which specifies a target framework of .NETStandard. Since your version of NuGet Package Manager is too old it does not recognise this target framework and converts it to an Unknown target framework and you end up with duplicate frameworks since there .NETStandard is used a few times in that NuGet package. This causes the error:

'AutoMapper' already has a dependency defined for 'Microsoft.CSharp' 

Unfortunately NuGet 2.12 is not available for Visual Studio 2012 but is available for Visual Studio 2013.

So either you need to update to Visual Studio 2013 or above, or you will have to use the older AutoMapper NuGet package which does not support .NETStandard.

like image 179
Matt Ward Avatar answered Sep 20 '22 21:09

Matt Ward