Thoughts from the Wet Coast

The musings of an ASP.NET Developer from Canada's We(s)t Coast

ASP.NET 5: 1 - The project.json file

Category: ASP.NET
Last Modified: May 2 2017
Nov 28 2014

Welcome to a new series on the latest version of ASP.NET – currently being called ASP.NET vNext (or ASP.NET 5).  Microsoft has been working on this latest version of ASP.NET for just over a year and last month they released a Beta 1 preview of the code and tooling as part of the Visual Studio 2015 Preview.

One of the immediately obvious changes for ASP.NET 5 projects is that most (if not all) of the project settings have been moved from the Visual Studio project file to a new project.json file.  Lets create a new ASP.NET 5 web site in Visual Studio 2015 (see Figure 1).

Figure 1: The Add New Web Application Dialog

image

Note the addition of two ASP.NET 5 templates – an Empty project and a Starter Web project with some starter content in, I am going to choose the Starter Web project.

Our new project will be shown as usual in the Solution Explorer (see Figure 2).  Outwardly the project looks similar to an AASP.NET v4.5 Web Application project in Visual Studio 2013.  There still is a “proj” file – although the ASP.NET 5 project has the file extension “.kproj”.  However, this file is really just a Visual Studio artefact.  It contains only the minimum amount of information required for Visual Studio to “host” the project.

Figure 2: The Starter Web Project

image

Most of the properties that developers care about have been moved to the project.json file.  This file controls almost all aspects of the project.  As you can see from Figure 3 there are nodes for webroot, version, dependencies, commands, frameworks, exclude, packExclude and scripts.

Figure 3: The project.json file

image

This file is synchronized with the Solution Explorer, so if I remove a dependency (reference) from the project file then the References node in Solution Explorer is updated.  Similarly if use the UI to change the References then the project.json file will immediately reflect that change. 

The dependencies node is a very interesting node.  In previous versions of Visual Studio we could add an assembly reference or a project reference, but ultimately all references were essentially assembly references.  In ASP.NET 5 the dependencies are essentially Nuget packages, and as Nuget packages have their own dependencies the References node in Solution Explorer can reflect those dependencies (Figure 4)

Figure 4: The References node

image

Another interesting node is the commands node.  This node allows you to define command line commands that can be executed by the “K” runtime – more on that in a future blog.

This is an exciting time to be an ASP.NET developer – if you want to keep up with what's changing please check back here as I explore the new features of ASP.NET 5.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Categories

Tags