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:
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
Delete the Roslyn compiler,
My Fix
I prefer the latter one. This is my solution:
Search entire solution for Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Search entire solution for Microsoft.Net.Compilers
Open Package Manager Console in Visual Studio:
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,
Recheck the result,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform is gone,
Recompile and run, the app works.
Check the changes. In Packages.config,
In Web.config,
Reference