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. In this post we will see How To Remove Roslyn support from ASP.NET Project.
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 –
- Remove Nuget Packages – “Microsoft.CodeDom.Providers.DotNetCompilerPlatform” & “Microsoft.Net.Compilers“
- 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.
Build your project and upload to the server. The errors related to Roslyn should be gone 🙂
Hope this post helps you! Cheers! 🙂