为什么要创建一个ASP.NET 5类库项目? [英] Why create an ASP.NET 5 Class Library project?

查看:151
本文介绍了为什么要创建一个ASP.NET 5类库项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚什么是ASP.NET 5类库(vNext)C#项目与ASP.NET做。为什么要建立这个模板的项目,而不是只是一个普通的C#类库项目?

I'm trying to figure out what an "ASP.NET 5 Class Library" (vNext) C# project has to do with ASP.NET. Why create a project with this template rather than just a regular C# "Class Library" project?

我喜欢新的功能,如project.json文件,而不是.csproj的文件等,但它似乎正确创建ASP.NET类库不会当项目无关与ASP.NET或IIS等,这只是为了业务逻辑层的项目。一个新的WebAPI ASP.NET网站最终会参考这个项目,但是这不是在这一点有关。

I like the new features, such as project.json file rather than .csproj file etc, but it doesn't seem right to create an "ASP.NET" class library when the project has nothing to do with ASP.NET or IIS etc. It's just a project for the business logic layer. A new WebApi ASP.NET web site will eventually reference this project, but that's not relevant at this point.

难道仅仅是严重命名?如果它只是被称为vNext类库,而不是使用看起来像一个web应用程序的图标?

Is it just badly named? Should it just be called "vNext Class Library" and not use an icon that looks like a web app?

推荐答案

有一些ASP.NET 5类库项目收益(的 .kproj)在类库项目(的.csproj的):

Why create an ASP.NET 5 Class Library project?

There are a number of benefits of ASP.NET 5 Class Library projects (.kproj) over Class Library projects (.csproj):


  1. ASP.NET 5类库轻松支持多个目标,如 aspnet50 aspnetcore50 交叉编译项目, net45 ,以及其他各种可移植类库的变化。这包括丰富的Visual Studio支持智能感知,通知您该API可用于哪些目标。

  2. 的NuGet包自动创建的,这是做类库一种极为常见的事。

  3. 当谈到喜欢的东西自动刷新Solution Explorer中的文件系统的变化时获得更好的效率。在源头控制,冲突更少当试图合并在* .csproj的文件冲突的更改。

  4. 可被编译的跨平台(部分原因是因为它不依赖于MSBuild的)

  1. ASP.NET 5 class libraries easily support cross-compiling projects to multiple targets, such as aspnet50, aspnetcore50, net45, and various other portable class library variations. This includes rich Visual Studio support for Intellisense to notify you which APIs are available for which targets.
  2. NuGet packages are automatically created, which is an extremely common thing to do with class libraries.
  3. Better productivity when it comes to things like automatically refreshing Solution Explorer when the file system changes. Fewer conflicts in source control when trying to merge conflicting changes in the *.csproj file.
  4. Can be compiled cross-platform (in part because it doesn't depend on MSBuild)

您可以从* .kproj项目中引用一个* .csproj的项目(这只是更容易与Visual Studio 2015年的新的preVIEW很多),但它总是可以用一些手动步骤。

You can reference a *.csproj project from a *.kproj project (this was just made a lot easier with the new preview of Visual Studio 2015), but it was always possible with some manual steps.

至于名字的推移,它是会很快得到解决的历史遗迹。新的项目类型是非常有用的远远超出了ASP.NET 5应用程序。预计在Visual Studio的未来preVIEW看到新的名称:

As far as the names goes, it's a relic of history that will soon be addressed. The new project type is useful far beyond ASP.NET 5 applications. Expect to see new names in a future preview of Visual Studio:


  • .NET控制台应用程序(跨平台)

  • .NET类库(跨平台)

使用的Visual Studio 2015年RC的发布你可以看到更新的项目模板名称:

With the release of Visual Studio 2015 RC you can see the updated project template names:


  • 类库(包)

  • 控制台应用程序(包)

这些使用 project.json 文件和.NET执行环境(DNX)来构建,运行和包(成的NuGet包)项目。

These use the project.json file and the .NET Execution Environment (DNX) to build, run, and package (into a NuGet package) the project.

这些项目模板继续在New Project对话框显示了网络节点下,但现在在主的Visual C#节点也显示为好。

These project templates continue to show up in the New Project dialog under the "Web" node, but now also show up in the main "Visual C#" node as well.

这篇关于为什么要创建一个ASP.NET 5类库项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆