Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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] :

enter image description here

to [netcoreapp2.2]:

enter image description here

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 ?

like image 478
Alaaeddine HFIDHI Avatar asked Apr 18 '19 09:04

Alaaeddine HFIDHI


1 Answers

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.

like image 87
Martin Ullrich Avatar answered Nov 11 '22 10:11

Martin Ullrich