1. 程式人生 > >VS2012 Nuget 安裝 AutoMapper時報錯的解決方法

VS2012 Nuget 安裝 AutoMapper時報錯的解決方法

for standard lin war syn test studio stand 解決方法

VS2012 在.net 4.0下安裝AutoMapper時,會報以下錯誤:

“AutoMapper”已擁有為“Standard.Library”定義的依賴項。

‘AutoMapper‘ already has a dependency defined for ‘Standard.Library‘.

經查應該是Nuget版本(VS2012的2.83版本)較低引起的,不支持Standard.Library框架。

解決方法有兩個:

方式一
NuGet 2.12支持AutoMapper 5.0.1 NuGet 包使用的.NETStandard框架,所以需要把NuGet升級為NuGet 2.12 或以上。
但NuGet2.12是不支持Visual Studio 2012,所以也需要把Visual Studio升級為2013。

方式二(采用)
降級AutoMapper的版本到兼容當前版本的NuGet,經測試4.1.1完美安裝上,並且順帶安裝了Microsoft.Bcl,可以使用.Net4.5的await和 async了
PM> Install-Package AutoMapper -Version 4.1.1
Installing ‘AutoMapper 4.1.1‘.
Successfully installed ‘AutoMapper 4.1.1‘.

參考:

http://majing.io/questions/557

VS2012 Nuget 安裝 AutoMapper時報錯的解決方法