Updated on Kisan Patel
The project.json
file is new to ASP.NET 5. It is used to define the project’s server side dependencies (discussed below), as well as other project-specific information.
The sections included in project.json by default with the default web project template are shown below.
{ "webroot": "wwwroot", "version": "1.0.0-*", "dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-beta5", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5", "Microsoft.AspNet.Mvc": "6.0.0-beta5", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5" }, "commands": { "web": "Microsoft.AspNet.Hosting --config hosting.ini" }, "frameworks": { "dnx451": { }, "dnxcore50": { } }, "publishExclude": [ "node_modules", "bower_components", "**.xproj", "**.user", "**.vspscc" ], "exclude": [ "wwwroot", "node_modules", "bower_components" ] "scripts" : { "postrestore" : [ "npm install" ] "prepare" : [ "grunt bower:install" ] } }
The webroot
section specifies the folder that should act as the root of the web site, which by convention defaults to the wwwroot folder. The version property specifies the current version of the project. You can also specify other metadata about the project such as authors and description.
The commands
section allows you to configure what certain command line commands should do (for instance, launch a web site or run tests).
The frameworks
section designates which targeted frameworks will be built, and what dependencies need to be included.
The exclude
section is used to identify files and folders that should be excluded from builds.
Likewise, publishExclude
is used to identify content portions of the project that should be excluded when bundling the site (for example, in production).
The scripts
section is used to specify when certain build automation scripts should run. Visual Studio now has built-in support for running such scripts before and after certain events. The default ASP.NET project template has scripts in place to run during postrestore and prepare that install client side dependencies using npm and bower.