简体   繁体   中英

Why is the Razor UI class library built as .NET Standard and not in .Net core

I've created a razor class library in a .Net core application. the library built as .NET Standard and the main web project and the others class libraries built as .Net core 2.2, When I'm trying to add a reference to my razor class library, I get this error:

project is not compatible with net standard 2.0

I changed the target framework in my razor class library from [netstandard2.0] :

在此处输入图片说明

to [netcoreapp2.2]:

在此处输入图片说明

and all works fine

I know that .Net standard allow the razor class library to target .Net core apps and .Net core framework apps but i know too that Razor class library is a feature of .Net core 2.1

Question : I need to know why is the razor class library built as .NET Standard and not in .Net core and should I change all my class libraries to .Net core 2 to be able to add .Net core class library as reference ?

ASP.NET Core 2.* also runs on .NET Framework, so you would need a .NET Standard library to use your Razor UI on both .NET Core and .NET Framework hosting applications, so it makes sense for the default template to work in both scenarios.

As ASP.NET Core 3+ will no longer run on .NET Framework, that behaviour may change. But the suggested default for "libraries" is currently .NET Standard, so it makes sense for the Razor UI library template to follow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM