How to solve – Could not find a part of the path bin roslyn csc.exe error

If you are trying to run Asp.Net application and getting given error in your browser even after successfully build and compile without getting any error.

Don’t worry! this is all happening because your build is trying to find \bin\roslyn\csc.exe because following packages have been added in your project. Just review you packages.config file, you can have both of them there.

Why Roslyn and what is use of Roslyn in Visual Studio

If you are running your project using .net Framework 4.5.2 with Visual Studio 2015/2017, you might have noticed that the project templates using Roslyn by default.  Actually Roslyn provides open-source C# and Visual Basic compilers with rich code analysis APIs. It enables building code analysis tools with the same APIs that are used by Visual Studio.

Read more about Roslyn :

https://github.com/dotnet/roslyn
https://en.wikipedia.org/wiki/.NET_Compiler_Platform

When to use Roslyn

If your project having Roslyn references and you are going to deploy it no server, you will get unexpected errors on the website as many hosting providers still have not upgraded their servers and hence do not support Roslyn. To resolve this issue, you will need to Downgrading it or remove the Roslyn compiler from the project template.

Way 1 : Run below code in the Package Manager Console to re-install/upgrade Nuget packages:

PM > update-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r


if you are not interested in using Roslyn, follow steps bellow to delete it

Way 2 : Remove Nuget packages, use the below commands from Nuget Package Console

PM> Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform PM> Uninstall-package Microsoft.Net.Compilers

After executing above command in Package Console, 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.

Try above steps to solve the issue if you are getting similar error.

Leave a Reply