Understanding ASP. NET 5 project structure and project files xproj, asp. netxproj

Source: Internet
Author: User

Understanding ASP. NET 5 project structure and project files xproj, asp. netxproj

ASP. NET 5 has made great changes in the project structure. The directory structure and project file content we used to be familiar with are not the same. This article will show you how to understand ASP. NET 5 is different from the previous one.

Visual Studio 2015 is used to create a brand new ASP. NET 5 website project, open VS2015, create a Web project ,. net framework. net 4.5 or above, select ASP. NET Web Application, select ASP.. NET 5 Website template to create a project, as shown in the following figure:

After creating a project, see the folder where the project is opened. Solution directory structure:

The directory structure of the actual folder. We can see several folders. Next we will introduce them one by one.

  • . Vs Hidden Folder: used to save what we will see in the VS2003-2013 project directory *. suo file, which is mainly used to save the status of the Visual Studio 2015 operation process, such as the file list you have enabled and other temporary information. If the ASP. NET 5 website uses IISExpress for troubleshooting, The applicationhost. config configuration file required by IISExpress will also be placed in the. vs \ config \ directory. These temporary files should not be placed in the source code version control, which is an improvement.
  • Artifacts Folder: used to save the Meta File case and output file that needs to be temporarily saved during the website construction process, that is, the bin and obj directories that were often seen in the project, and are now moved to this folder in a unified manner. This folder should not be added to version control, which is another major improvement.
  • Src Folder: used to place all projects in this solution. Therefore, the main source code is stored in this directory. Each directory under this directory is an independent project.
  • *. Sln project file: This file does not need to be described. It is exactly the same as the project solution we have seen before.
  • Global. json global configuration file: this file is usually placed in the same layer folder as the project solution for reference. It is mainly used to define the path list and the default sdk version to be "automatically imported" to the solution file. For example, if the "projects" parameter is set, all projects in the src and test folders will be imported. For example, if you want to add an ASP. NET 5 project to the current project, you only need to move the project directory (src \ projectName) directly to the src \ directory of the current solution, nothing else needs to be set!

Next, go to the ASPNET5WebApp project folder (for example). the directory structure of the project is also very different from the previous one. I will introduce it from top to bottom:

  • Bower_componentsFolder: Because Visual Studio 2015 is integrated with the most common bower tools on the Web Front-end, when all the "front-end" suites are installed using the bower command in the future, the kit is automatically installed in the bower_components folder. This folder should not be added to version control.
  • CompilerFolder: ASP. net mvc 6 (equivalent to ASP. NET 5). It will support Razor pre-compilation, so that you can pre-compile all Razor pages during website deployment to speed up website execution. There isCompiler \ Preprocess \ RazorPreCompilation. csFile, you can set whether to enable the Razor automatic compilation function. (Razor pre-compilation can be enabled as long as the program code is uncommented)

  • ControllersFolder: This is the Controllers private folder of ASP. net mvc 6.
  • MigrationsFolder: This is the dedicated DbMigration folder of Entity Framework.
  • ModelsFolder: This is the special Models folder of ASP. net mvc 6.
  • Node_modulesFolder: Because Visual Studio 2015 integrates common npm kit management tools of nodejs, all npm components can be installed using npm commands in the future, and the default settings of these components will be installedNode_modulesFolder. Note that this folder should not be added to version control.
  • PropertiesFolder: this folder is similar to the previous one. It is also used to save special settings of some projects, such as the website release configuration file. But in addition, there is an additional deletetoken. cs category file. This file is mainly used to define a Model Class (set by the Application) for you to read application configuration parameters in a strongly typed manner.
  • ViewsFolder: This is the Views dedicated folder of ASP. net mvc 6.
  • WwwrootFolder: this folder is all new. for ASP. NET 5 in the future, as long as it is a "static file", such as js, css, images ,... Such static files are stored in this folder to avoid mixing the front-end files with the back-end program code. ASP. NET5 is completely modularized. IIS is no longer the only container for running MVC programs. Any running container compatible with DNX can run the MVC program. The program release package is divided into two parts: approot and wwwroot, store the application assembly (or source code) and static files respectively to achieve better separation.
  • *. XprojFile: This is a new generation of project files, different from the previous *. csproj and *. vbproj project file. This project file is much smaller and the content format is similar. The same is the XML format and the same is the content that MSBuild will reference. But the biggest difference is that the new version*. XprojYou do not need to explicitly list all files. Files in all projects do not need to be added or removed. files will be automatically added to the project as long as they appear in the project directory! Further strengthen the conventions over the configuration principle. delete files that cannot be used in the project. In this way, you can clear a lot of junk files that shouldn't exist in the project. I believe you are very touched by this.
  • *. Xproj. userFile: this file is used to record the status of the project in Visual Studio 2015 development tools, such as the file list you have enabled and other temporary information. This file should not be added to version control.
  • Bower. jsonFile: This is the configuration file dedicated to the bower tool, there is no direct relationship with ASP. NET 5, the relevant files please refer to here: http://bower.io/docs/config/
  • Config. jsonFile: This is the ASP. NET 5 project configuration file. All application parameter settings and connection strings are defined here.
  • Gulpfile. jsonFile: This is a configuration file dedicated to the gulp front-end process management tool, which can help you complete some automation work. This file has no direct relationship with ASP. NET 5, the relevant files please refer here: https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md
  • MessageServices. csFile: When you enable two-factor authentication in ASP. NET Identity, this file allows you to write the code for sending Email or SMS messages.
  • Package. json file: This is nodejs npm tool dedicated configuration file, and ASP. NET 5 is not directly related, the relevant files please refer to here: https://docs.npmjs.com/
  • Project. jsonFile: this file is an important ASP. NET 5 project configuration file, many important settings are from the web. config is changed to this file. If you want to write ASP. NET 5 trend must have a deep understanding of the project. json file configuration method, detailed file see: https://github.com/aspnet/Home/wiki/Project.json-file
  • Project. lock. jsonFile. the json file defines the NuGet suite to be loaded for the project, and Visual Studio 2015 automatically loads the dependent suite of the suite. Therefore, each time a project is built in a new environment, it may take 3 ~ Package Restore is performed at 5 times. The project. lock. json file is similar to the previous packages. config file, which clearly lists all the NuGet suites to be loaded. This file is automatically generated by Visual Studio 2015, but we recommend that you add version control to shorten the CI build time.
  • Project_Readme.htmlFile: project description. There are many Reference Links on this webpage, which allows you to learn more about ASP. NET 5 development methods.
  • Startup. csFile: this file is an important ASP. NET 5 website startup portal, due to ASP. NET 5 Execution lifecycle change, the previous global. the asax file is replaced by Startup. the Startup class in the cs file. In other words, when ASP. NET 5 applications are started in the future, they will be executed from the Startup class as soon as they are started!

ASP. NET 5's new project directory structure, xproj project files, and some important files are all part of the need for extra learning, uncle Tom of the blog Park has compiled a series of tutorials by reading Microsoft's source code and some articles on the Internet. All the code is verified in VS 2015 RC. The author also set up a directory http://www.cnblogs.com/TomXu/p/4496545.html for these articles, this series of articles I also posted on the public account opendotnet, welcome to follow the public account opendotnet, read through historical information:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.