Roslyn csc.exe and vbc.exe deployment on shared hosting

Roslyn compilation is now default with .NET 4.5 means if you create any web application either Web Forms or MVC using .NET 4.5 you get this compilations bits pre-installed in your project.

Why use Roslyn compilation?

In nutshell, this enables many features which is very useful when developing application as well as when application is deployed on server.

(i) When Developing Application
Earlier when we made any change in C# code, this requires build before we see result on browser, this is not required when Roslyn is default compilation.

(ii) When Application is deployed on server
As you know we write C# and HTML mixed codes on ASPX page or even on MVC view page (Razor syntax). This always requires some sort of compilation to display result to user and this affects page load time. Application which has Roslyn improves this page load time way better than before.

So, with these two benefits you must have concluded that Roslyn is super useful. There are many other features of Roslyn which you can search on MSDN.

Roslyn on shared hosting

If you are trying to publish Roslyn feature on shared hosting you should read this before you proceed. You might know, when we deploy application this runs on Full Trust mode. Shared hosting companies does not allow Full Trust applications, they override this globally with Medium Trust due to security restrictions as they are hosting multiple customers website and they don’t want one application affects another by any chance.

Roslyn compilation will only work with Full Trust so on some shared hosting you might face challenges. I would suggest ask your hosting provider if they support Full Trust.

If shared hosting does not support Full Trust you should not deploy application with Roslyn, this will display you some sort of .exe file missing errors. Even you can’t do .exe files FTP on shared server.

What to do now? How to deploy without Roslyn or without .exe files on shared servers?

You can deploy even without Roslyn with no change in code. Open NuGet Package Manager window and uninstall Microsoft.CodeDom.Providers.DotNetCompilerPlatform package and rebuild & republish. This uninstallation also removes CodeDom configuration from web.config file. This will solve your purpose. Basically this will not generate any csc.exe, vbc.exe files inside bin folder.

Hope this helps.


Post a Comment

Popular posts from this blog

Lambda two tables and three tables inner join code samples

Migrating database from ASP.NET Identity to ASP.NET Core Identity