February 29, 2016 by Nitesh

Remove Roslyn support from ASP.NET Project


VS2015 has been launched and if you’re using .net Framework 4.5.2 to create projects using VS2015, you might have noticed that the project templates use Roslyn by default. If you’re not aware of Roslyn, it is a set of open-source compilers and code analysis APIs for C# and Visual Basic .NET languages from Microsoft. You can see the code here.

Many hosting providers still have not upgraded their servers and hence do not support Roslyn. this is quite common in shared hosting servers. If you upload a project with Roslyn references, you will get unwanted errors on the website. To resolve this issue, we will need to remove Roslyn from the project template. We will see how this can be done in this post.

It’s a 2 step-process to remove Roslyn from your project –

  1. Remove Nuget Packages – “Microsoft.CodeDom.Providers.DotNetCompilerPlatform” & “Microsoft.Net.Compilers
  2. Cleanup web.config file.

To remove Nuget packages, use the following commands from Nuget Package Console –

uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
uninstall-package Microsoft.Net.Compilers

After you do this, your web.config file should be auto-updated. In case it is not, look for the below code in web.config file and if it is found, delete this piece of code.

<system .codedom>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"></compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"></compiler>

Build your project and upload to the server. The errors related to Roslyn should be gone 🙂

Hope this post helps you! Cheers! 🙂


Support us!

If you like this site please help and make click on any of these buttons!

Powered by WordPress Popup