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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With