依赖Asp.net Core的类库

依赖Asp.net Core的类库

用Visual Studio创建的类库想依赖Asp.net Core的某些组件,比如Microsoft.AspNetCore.Mvc.Core,在.netcore 3.1之后不再单独提供nuget包,应该怎么办呢?直接在.csproj文件里面添加FrameworkReference:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

</Project>

参考

https://stackoverflow.com/questions/59972153/how-to-install-microsoft-aspnetcore-mvc-core-with-version-3-1-0-from-nuget

https://learn.microsoft.com/zh-cn/aspnet/core/fundamentals/target-aspnetcore?view=aspnetcore-7.0&tabs=visual-studio#determine-which-aspnet-core-versions-to-support

posted @ 2023-11-11 21:57  tubo  阅读(19)  评论(0编辑  收藏  举报