此刻,我正在将一个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包
发布评论