将一个 .net core 类库项目的 TargetFramework 由 netstandard2.0
改为 netstandard2.1
,但项目中引用的一些 .net core 的 nuget 包(比如 Microsoft.Extensions.Http )没有对应的 .net core 3.1 版本,尝试添加 FrameworkReference
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Build 时却报错
The FrameworkReference 'Microsoft.AspNetCore.App' was not recognized
请问如何解决?
https://andrewlock.net/converting-a-netstandard-2-library-to-netcore-3/
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.1.3" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
</ItemGroup>
</Project>
`Microsoft.AspNetCore.App` 都 asp.net core 特有的,netstandard 的项目不能引用,可以考虑像上面园友说的,增加 `netcoreapp3.0`/`netcoreapp3.1` target