首页新闻找找看学习计划

.NET Core netstandard2.1 项目引用 Microsoft.AspNetCore.App 的问题

0
悬赏园豆:50 [待解决问题]

将一个 .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

请问如何解决?

dudu的主页 dudu | 高人七级 | 园豆:39250
提问于:2020-03-30 14:52
< >
分享
所有回答(1)
0

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>
czd890 | 园豆:8638 (大侠五级) | 2020-03-31 11:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册