ASP.NET 5 CompilerOptions - languageversion in project.json

Feb 26, 2015

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:

Choose C# language version

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:

C# 2 selected and Task or AutoProperty does not work

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

C# 2 selected and Task or AutoProperty does not work on linux

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 !!

Language Version option in VS2013 - ASP.NET 4

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