3

I am confused. Years back I installed Microsoft.CodeDom.Providers.DotNetCompilerPlatform from Github: Microsoft.CodeDom.Providers.DotNetCompilerPlatform

Now I could get the newest C# compiler in my Asp.Net sites, independent of the .Net Framework version, simply by including the package when deploying to the production server.

However, this summer things changed. If I have understood things correctly, the .Net Framework version 4.8 now defaults to using C# 7.3.

My question is: Does that also apply to Asp.net? Or do I still need to deploy the compiler from Github to my web server?

Is C# 7.3 compiler included in .Net Framework 4.8?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Poul Bak
  • 10,450
  • 5
  • 32
  • 57

1 Answers1

2

The comments are wrong!

Asp.Net websites still use C# 7.0 compiler, despite the fact that I have .Net 4.8 installed!

I took the chance and uninstalled the 'Roslyn' compiler from Github on one of my web sites(link in question). Now I got a lot of errors when compiling.

Example of error (this is a property):

public bool IsReusable => false;

That doesn't work in C# 7.0. So I will have to keep the 'Roslyn' compiler on my websites to get C# 7.3

Update:

For anyone, who have just installed the 'Roslyn' compiler from Github: You must manually set the langversion in Web.config, like this:

  <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:7.3 /nowarn:1659;1699;1701" />

Now asp.net will use the C# 7.3 compiler.

Poul Bak
  • 10,450
  • 5
  • 32
  • 57
  • any experience *updating* the roslyn compiler... or how to get the latest "roslyn" to add to the Bin directory? After setting up a new empty website, targeting Framework 4.8, I used nuget to search for CodDom, it pulled down 3.6.0, but no roslyn directory in the Bin... – Margo Noreen Dec 09 '20 at 19:30