You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The primary benefits of compiled views is improved performance by eliminating compile times of Razor views. They can also provide static compilation benefits by highlighting compile errors during development and can simplify deployment by avoiding the need to deploy any *.cshtml files as they end up pre-compiled in the containing Assembly.
Install ServiceStack.Razor.BuildTask
To enable compiled razor views you need to add the ServiceStack.Razor.BuildTask NuGet Package to the project containing your Razor *.cshtml pages, i.e:
PM> Install-Package ServiceStack.Razor.BuildTask
This doesn't add any additional dlls to your project, instead it just sets the BuildAction to all *.cshtml pages to Content and registers an MSBuild task to your .csproj project file set to pre-compile razor views on every build.
Register Compiled Assembly to RazorFormat Plugin
To register assemblies containing compiled razor views with Razor Format you just need to add it to RazorFormat.LoadFromAssemblies, e.g:
The Compiled Views support continues to retain a great development experience in DebugMode as all Razor Views are initially loaded from the Assembly but also continues to monitor the file system for modified views, automatically compiling and loading them on the fly so AppDomain reloads aren't required to see changes.
The ServiceStack.Gap project shows how to extend Compiled Razor Views and use them to create embedded ServiceStack solutions that can be ILMerged down to a single .exe.