asp.net - How to use C# 6 with Web Site project type? -


updated existing web site project type visual studio 2015, changed framework 4.6.

i expected have new features available in code behind files.

unfortunately i'm getting errors like:

error cs8026: feature 'expression-bodied property' not available in c# 5. please use language version 6 or greater.

or e.g.:

error cs8026: feature 'interpolated strings' not available in c# 5. please use language version 6 or greater.

i did quick google check , found a guy posting comments in blog posting of scottgu (search "8026" on page).

since not understand solution, plus want have solution more visible, i've created posting.

my question:

how can have visual studio 2015 project of type web site (i.e. not web application) recognize c# 6 features?

i've tested asp.net mvc 5 (tested 5.2.3), , mileage may vary other web frameworks, need add roslyn codedom| nuget package

codedom providers .net compiler...

replacement codedom providers use new .net compiler platform ("roslyn") compiler service apis. provides support new language features in systems using codedom (e.g. asp.net runtime compilation) improving compilation performance of these systems.

pm> install-package microsoft.codedom.providers.dotnetcompilerplatform 

https://www.nuget.org/packages/microsoft.codedom.providers.dotnetcompilerplatform/

the nuget package should add dll files , add following web.config.

  <system.codedom>     <compilers>       <compiler language="c#;cs;csharp" extension=".cs" type="microsoft.codedom.providers.dotnetcompilerplatform.csharpcodeprovider, microsoft.codedom.providers.dotnetcompilerplatform, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" warninglevel="4" compileroptions="/langversion:6 /nowarn:1659;1699;1701" />       <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="microsoft.codedom.providers.dotnetcompilerplatform.vbcodeprovider, microsoft.codedom.providers.dotnetcompilerplatform, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" warninglevel="4" compileroptions="/langversion:14 /nowarn:41008 /define:_mytype=\&quot;web\&quot; /optioninfer+" />     </compilers>   </system.codedom> 

if it's still missing. try adding yourself.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -