ASP.NET 5 CompilerOptions - languageversion in project.json

Note: [Deprecated Content] This was written while ASP.NET and .NET Core was in beta (around beta5 or beta6). Since then a lot of stuffs have changed and moved around. Stuffs described below may or may not be true for current stable releases of ASP.NET Core. I recommend not to follow along and get confused. Use official configuration documentation that explains it correctly - docs.asp.net

ASP.NET 5 removed the web.config XML based configuration files and bring JSON based project.json and other similar files to maintain configuration related to your application.

project.json is the main file that contains meta-information / configuration for running your ASP.NET 5 application.

This JSON file consist of a node named compilationOptions which defines a child called languageVersion.

Currently ASP.NET 5 only supports C# language. languageVersion can be one of the following options:

It provides way to choose which version of C# you wish to use for your application to compile against.

I selected csharp2 from the option intellisense list, added an AutoProperty and Task to my code. Visual studio immediately starts giving red swiglies similar to following:

This change will also give error on Linux or MacOS X system when compiled:

I also see almost similar language version option in older version of ASP.NET and other project types in Visual Studio 2013. I am not yet sure if it was already there before ASP.NET 5 but atleast now I know it and you know it too !!

Note: At the time of writing, ASP.NET 5 and .NET 4.6 are in BETA 3 and above information may change in future or final version.

Happy coding