Here are two methods to solve roslyn\csc.exe error:
Solution:
Method 1: Before recompiling, execute the clear solution and the problem is solved.
Method 2: Enter in the nuget package manager console: Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r