global.json和src文件夹有多重要? [英] How important is the global.json and src folder?

查看:336
本文介绍了global.json和src文件夹有多重要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS 2015中,当您使用这种方法创建新的MVC 6.0应用程序时:

In VS 2015, when you create a new MVC 6.0 application using this approach:

File-->New-->Project-->ASP.NET Web Application-->ASP.NET 5 Preview Templates

您最终在磁盘上具有以下文件结构:

You end up have the following file structure on disk:

  • 人工制品
  • src
  • MyProject.sln
  • global.json

相反,如果我决定先创建一个空白解决方案,像这样:

Instead if I decide to create a blank solution first like so:

 File-->New-->Project-->Other Project Types-->Visual Studio Solutions-->Blank Solution

并开始向该解决方案添加一个新的ASP.NET Web应用程序项目;您最终会拥有 没有global.json文件且没有src文件夹的文件结构.

And start adding a new ASP.NET Web Application project to this solution; you end up having a file structure that doesn’t have a global.json file and no src folder.

根据文档 global.json文件用于整体配置解决方案.它仅包括两个部分,默认情况下为project和sdk.

projects属性指定哪些文件夹包含解决方案的源代码.默认情况下,项目结构将源文件放置在src文件夹中,从而允许将构建工件放置在同级文件夹中,从而更容易从源代码管理中排除此类内容.

The projects property designates which folders contain source code for the solution. By default the project structure places source files in a src folder, allowing build artifacts to be placed in a sibling folder, making it easier to exclude such things from source control.

sdk属性指定打开解决方案时Visual Studio将使用的DNX(.Net执行环境)的版本.在此处而不是在project.json中进行设置是为了避免方案中的不同项目针对不同版本的SDK的情况.

The sdk property specifies the version of the DNX (.Net Execution Environment) that Visual Studio will use when opening the solution. It’s set here, rather than in project.json, to avoid scenarios where different projects within a solution are targeting different versions of the SDK.

问题1)

如上所述,如果我选择先创建一个空白解决方案,则不会有global.json文件.

As mentioned above, if I choose to first create a Blank Solution, I won’t be having a global.json file.

没有global.json文件是否以任何形状或形式影响应用程序的行为?例如,当我部署或与构建工件进行交互时?

Is not having a global.json file impact the application’s behavior in any shape or form? For example when I deploy or the interaction with the build artifacts?

问题2)

如果确实有影响,那么我应该手动创建此global.json文件吗?

If it does have an impact, then should I manually be creating this global.json file?

问题3)

在撰写本文时,是否存在推荐的方法来在ASP.NET 5中创建多层应用程序?

As of this writing, is there a recommended approach for creating a multi-layered application in ASP.NET 5?

我应该首先创建MVC项目并开始向该项目添加类库吗?

Should I first create the MVC project and start adding Class Libraries to the project?

首先我应该先创建一个空白解决方案,然后开始将类库和Web应用程序添加到解决方案中(知道我将没有global.json文件或src文件夹)吗?

Should I first start by creating a Blank Solution and start adding the Class Libraries and the Web Application to the solution (knowing I won’t have global.json file nor a src folder)?

推荐答案

您已经注意到,这似乎是针对ASP.NET 5创建解决方案的新方法.global.json文件指定了一些解决方案级别设置.特别是,它定义了 DNX运行时设置.

As you've noted, this seems to be the new way of creating solutions when targeting ASP.NET 5. The global.json file specifies some solution-level settings. In particular, it defines the DNX runtime settings.

我已经看到了src/test文件夹结构的两种方法.如果您查看 MVC团队在做什么,他们会将src/test文件夹合并到存储库根目录中.例如Github上的许多项目在根目录中都有一个src目录.因此,只要您可以在项目的根目录中使用global.json和解决方案文件,就可以很好地与现有做法保持一致.

I've seen two approaches to the src / test folder structure. If you look at what the MVC team is doing, they incorporate the src / test folders into the repository root. Many projects on, e.g., Github have a src directory in the root. So as long as you're OK with your global.json and solution files in the root of your project, it seems to align well with existing practices.

如果您查看.NET团队使用 .NET 5核心框架所做的工作,那么您即使没有global.json文件,也会看到类似的模式.他们的许多库都有src和 test 子目录.

If you look at what the .NET team is doing with the .NET 5 Core Framework, you'll see a similar pattern, albeit without the global.json file. Many of their libraries have src and tests subdirectories.

我将尝试按照MVC团队目前正在做的事情来设计我的项目,直到我对.NET 5,DNX和其他内容有了更好的了解.它确实在您的项目上强加了一定的结构,但是VS 2013和.NET 4.5也是如此.

I am going to try to pattern my projects after what the MVC team is doing for the time being, until I have a better understanding of .NET 5, DNX, and the rest. It does impose a certain structure on your projects, but then so did VS 2013 and .NET 4.5.

这篇关于global.json和src文件夹有多重要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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