[英]Build a simple class library for ASP.NET Core and MVC 5 Applications
I want to build a simple C# Class Library that can be referenced from both ASP.NET Core 1.1 MVC and MVC 5 web applications. 我想构建一个可以从ASP.NET Core 1.1 MVC和MVC 5 Web应用程序引用的简单C#类库 。 By simple I mean that the library just contains some enums and some string constants , ie no additional dependencies.
简单来说,我的意思是该库只包含一些枚举和一些字符串常量 ,即没有其他依赖项。
I have tried building the library as a .NET Core Class Library, but it seems this cannot be referenced by MVC 5 applications and vice versa. 我曾尝试将该库构建为.NET Core类库,但是看来MVC 5应用程序无法引用该库,反之亦然。 Currently, all components (class library and web applications) are running in the same solution.
当前,所有组件(类库和Web应用程序)都在同一解决方案中运行。
Is there a way of achieving this? 有没有办法做到这一点?
Thanks. 谢谢。
You want a .NET Standard class library. 您需要一个.NET Standard类库。 Be sure to pick a version of the .NET standard that both .net core and full framework supports (1.5 works for 4.6.2 and net core)
确保选择.net核心和完整框架都支持的.NET标准版本(1.5适用于4.6.2和net核心)
See matrix in this article for full compatibilities: 有关完整兼容性,请参见本文中的矩阵:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.