Automapper安装报错

问题描述
在Visual Studio Premium 2012用NuGet 添加依赖AutoMapper失败报错:

Operation failed

‘AutoMapper’ already has a dependency defined for ‘Microsoft.CSharp’.
NuGet Package Manager 版本2.8.60318.667

问题解决
这个主要是因为NuGet Package Manager 版本比较旧,它不支持AutoMapper所使用的.NETStandard框架。

有两种方式:

方式一

NuGet 2.12支持AutoMapper 5.0.1 NuGet 包使用的.NETStandard框架,所以需要把NuGet升级为NuGet 2.12 或以上。

但NuGet2.12是不支持Visual Studio 2012,所以也需要把Visual Studio升级为2013。

方式二

降级AutoMapper的版本到兼容当前版本的NuGet

PM> Install-Package AutoMapper -Version 4.2.1
显示如下:
Installing ‘AutoMapper 4.2.1’.
Successfully installed ‘AutoMapper 4.2.1’.

猜你喜欢

转载自blog.csdn.net/zh_geo/article/details/77581272