Who uses Roslyn for publication
If your project has Roslyn references and you are interested in posting it to an ISS server , you will probably experience unwanted errors on your website since many ISPs hosting have not yet updated their servers and consequently do not support Roslyn.
To resolve this issue, you will have to remove the Roslyn compiler from the project . Removing Roslyn should not affect the functionality of your code. It worked quietly for me and in other projects (C # 4.5.2) that I worked on.
Perform the following steps:
Remove the following Nuget packages by using the command line below () or you can use the Nuget Package manager by right-clicking the Root of your Project's Solution and removing them ).
PM> Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
PM> Uninstall-package Microsoft.Net.Compilers
Remove the following code from the Web.Config file. Use this method only if step 1 does not solve your problem.
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
Restart your IIS and your issue should be resolved.
Translated and adapted from IIS publishing problems .