Who uses Roslyn for publication
If your project has references Roslyn and you are interested in posting it on a iss server, you will probably get unwanted errors on your website since many providers of hosting have not updated their servers and consequently do not support Roslyn.
To solve this problem, you will have to remove the Roslyn compiler from the project. Removing Roslyn should not affect the functionality of your code. It worked smoothly for me and other projects (C# 4.5.2) I worked on.
Take the following steps:
Remove the following Nuget packages using the command line provided below (or you can use the Nuget Package Manager by right-clicking the Solution Root of your Project 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 problem must be solved.
Translated and adapted from IIS Publishing problems.
Which version of . net is sending your webApi compiled?
– Thiago Araújo