This works in MVC 5 (tested 5.2.3), you just need to add the roslyn code dom Nuget package
CodeDOM Providers for .NET Compiler…
Replacement CodeDOM providers that use the new .NET Compiler Platform (“Roslyn”) compiler as a service APIs. This provides support for new language features in systems using CodeDOM (e.g. ASP.NET runtime compilation) as well as improving the compilation performance of these systems.
PM> Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/