A fix to Roslyn issue when compiling in .NET Code.
Introduction
This is long existing issue, at least since VS 2015. There are two possible fixes, one is updating the Roslyn to make the code work, another one is deleting Roslyn. I prefer the latter and will introduce my solution.
The structure of this article:
- Introduction
- Problem
- Two Possible Fixes
- Update the Roslyn compiler
- Delete the Roslyn compiler
- My Fix
Problem
When running a MVC web application, we got this error message:
![Could not find a part of the path ... bin\roslyn\csc.exe]()
Possible Fixes
Search online, we saw two possible solutions in one thread: Could not find a part of the path ... bin\roslyn\csc.exe, the suggestions as below:
Update the Roslyn compiler
![Could not find a part of the path ... bin\roslyn\csc.exe]()
Delete the Roslyn compiler,
![Could not find a part of the path ... bin\roslyn\csc.exe]()
![Could not find a part of the path ... bin\roslyn\csc.exe]()
My Fix
I prefer the latter one. This is my solution:
Search entire solution for Microsoft.CodeDom.Providers.DotNetCompilerPlatform
![Could not find a part of the path ... bin\roslyn\csc.exe]()
Search entire solution for Microsoft.Net.Compilers
![Could not find a part of the path ... bin\roslyn\csc.exe]()
Open Package Manager Console in Visual Studio:
![Could not find a part of the path ... bin\roslyn\csc.exe]()
Run the following command if any one of the above existing,
PM> Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
PM> Uninstall-package Microsoft.Net.Compilers
For ours, we run the first,
![Could not find a part of the path ... bin\roslyn\csc.exe]()
Recheck the result,
![Could not find a part of the path ... bin\roslyn\csc.exe]()
Microsoft.CodeDom.Providers.DotNetCompilerPlatform is gone,
![Could not find a part of the path ... bin\roslyn\csc.exe]()
Recompile and run, the app works.
Check the changes. In Packages.config,
![Could not find a part of the path ... bin\roslyn\csc.exe]()
In Web.config,
![Could not find a part of the path ... bin\roslyn\csc.exe]()
Reference