我使用以下.csproj文件创建可重用的.NET Standard 2.0 DLL:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="*" />
<PackageReference Include="System.Security.Claims" Version="4.*" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.*" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.*" />
<PackageReference Include="IdentityModel" Version="3.*" />
</ItemGroup>
</Project>
当我尝试在asp.net core 2.0项目中添加对它的引用时,出现此错误:
Error CS1705 Assembly 'SharedLib' with identity 'SharedLib, Version=3.7.4.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.AspNetCore.Mvc.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.AspNetCore.Mvc.Abstractions' with identity 'Microsoft.AspNetCore.Mvc.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
似乎我的SharedLib需要Microsoft.AspNetCore.Mvc.Abstractions
2.1.1为什么会这样?如何使共享库与Asp.net core 2.0兼容?