1
votes

I have created a Asp.Net Core Web Application that targets the full .Net Framework. This was accomplished by using the Visual Studio ASP.NET Core Web Application (.NET Framework) template.

I'd like to create some tag helpers that I use in this Web Application and I'd like to place them in a library dll. Initially I tried adding a new project to my solution of type Class Library (.NET Core) to place them in but I was unable to reference that library from the web project. When I tried to reference it via Visual Studio I received a dialog that said the project reference was not supported because the Class Library has a target framework that is incompatible with the targets in my Website Project.

So as an alternative, I added a regular Class Library project to the solution via the Visual Studio Class Library template. I am able to add a reference from my Web Project to this class library successfully. However, in this Class Library project I can't find a way to reference Microsoft.AspNetCore.Razor.Runtime which is necessary if I'm going to be able to put my tag helpers in the library.

So I'm at a dead end with both approaches. How can I put my ASP.NET Core tag helpers in a class library that I can reference from my ASP.NET Web Project that targets the full .net framework?

1

1 Answers

1
votes

When I tried to reference it via Visual Studio I received a dialog that said the project reference was not supported because the Class Library has a target framework that is incompatible with the targets in my Website Project.

This usually means you both libraries target different things, i.e. if your Class library targets netstandard1.6 and your web application targets net452 its not going to work.

Either your web application needs to target netcoreapp1.0 or your class library has to target netstandard1.0. Use the .NET Standard Library matrix here to see which netstandard1.x moniker supports which platform.

So if your web application targets net452, you have to target netstandard1.0, netstandard1.1 or netstandard1.2. netstandard1.3 and higher don't work, because it requires .NET Framework 4.6.

If you use a library which requires netstandard1.3 or higher, you have to target multiple platforms. i.e. net452 and netstandard1.3.

Then net452 will be used in projects which target net452 and netstandard1.3 will be used in netcoreapp1.0 applications or other class libraries which target netstandard.