在netstandard中使用Microsoft.AspNetCore.All包

编程入门 行业动态 更新时间:2024-10-26 13:29:34
本文介绍了在netstandard中使用Microsoft.AspNetCore.All包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

此刻,我正在将一个ASP Web API移植到.Net Core。

该api使用一个类库,该类库提供ActionFilterAttribute类的一些实现。 / p>

所以我也必须移植此类库。 当我尝试将nuget包Microsoft.AspNetCore.All添加到类库时,我收到此错误:

.AspNetCore.All 2.0.0与 netstandard2.0

不兼容。当我将目标框架更改为netcoreapp2时。 0,我可以安装该软件包,但是我当然需要此目标类型的入口点。

如何创建可以使用的netcore类库Microsoft.AspNetCore.All软件包

问候

解决方案

元软件包 Microsoft.AspNetCore.All 仅适用于.NETCoreApp。这是设计,因为它明确地旨在作为.NET上运行的Web应用程序的便捷包。核心。为了在发布时发挥作用(剥离未使用的依赖项),它需要.NET Core运行时存储区,该存储区仅适用于.NET Core本身。

全部其他项目,包括在.NET Standard上运行的库项目,也包括在完整.NET Framework上运行的所有项目,都应改用单个程序包引用。

因此,而不是引用 Microsoft.AspNetCore.All ,您将引用例如 Microsoft.AspNetCore 或 Microsoft.AspNetCore.Mvc 来获取您的 ActionFilterAttribute 。

At the moment I'm porting an asp web api to .Net Core.

The api uses a Class library which provides some implementations of the ActionFilterAttribute class.

So I have to port this class library as well. When I tried to add the nuget package Microsoft.AspNetCore.All to the class library I recived this error:

Package Microsoft.AspNetCore.All 2.0.0 is not compatible with netstandard2.0

When I change the target framework to netcoreapp2.0, I'm able to install the package, but of course I need an entry point for this target type.

How can I create a netcore class library which can use the Microsoft.AspNetCore.All package

Greetings

解决方案

The metapackage Microsoft.AspNetCore.All is only available for .NETCoreApp. This is by design since its explictly targeted as a convenience package for web applications running on .NET Core. In order to work its magic at publishing time (stripping of unused dependencies), it requires the .NET Core runtime store which is only available for .NET Core itself.

All other projects, including library projects running on .NET Standard but also including all projects that run on the full .NET Framework, should use individual package references instead.

So instead of referencing Microsoft.AspNetCore.All, you would be referencing e.g. Microsoft.AspNetCore, or Microsoft.AspNetCore.Mvc to get your ActionFilterAttribute.

更多推荐

在netstandard中使用Microsoft.AspNetCore.All包

本文发布于:2023-11-14 14:07:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587418.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:netstandard   Microsoft   AspNetCore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!