Our solution, where after compiling locally, copies the views from the standard /view folder in the build output into a /client/views folder on in the web root. We're looking to take advantage of the RazorGenerator precompiled views and OOTB features mentioned by Kam in this blog post.


Assumption is that Sitecore uses the AssemblyIdentity collection below to pull a list of assemblies and loop thru trying to find a match based on the view renderings path listed on the Sitecore item.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
          <assemblyIdentity name="My.Project" />
          <assemblyIdentity name="My.OtherProject" />

Can anybody confirm this is how Sitecore does this match?

Does anybody have any experience overriding the RazorGenerator.MSBuild to build a custom path for the PageVirtualPath decorated attribute?



Or have other suggestions on how this works?

Update: Ticket into Sitecore support for clarification, but in meantime ran a test by:

  1. removing our route modification override
  2. updated all view renderings by quick yml unicorn sync to set default path
  3. deleted our custom view folder to verify they were getting pulled from assembly

That indeed worked and points to the PageVirtualPath as the mapping mechanism.

Guessing best route now is to pull RazorGenerator code down and modify to take in some additional build config properties to overwrite the base path when compilation is done.

  • I don't have a real answer, but enable debug logging and check for lines that start with PrecompiledViewAssembly, that should tell you if it's locating precompiled views in your assemblies. The logic is in the root of Sitecore.Mvc if you decompile it. Nov 9, 2018 at 21:27
  • Thanks for the suggestion. I'll get to diggin' into the Sitecore assemblies to see and let you know what I find. Nov 9, 2018 at 23:23
  • I assume that you're updating the ViewLocationFormats of the razor engine? If so, I would expect that it would just work as expected Nov 9, 2018 at 23:25

1 Answer 1


Was hoping for something more elegant but this seems to work. Adding a simple directive at the top of each razor view does the trick.

VirtualPath: ~/Client/Views/Feature/Renderings/Sample.cshtml 

Some quick settings

<setting name="Mvc.RenderersViewFolder">
        <patch:attribute name="value" value="/Client/Views/{1}/Renderings" />
  <setting name="Mvc.UsePhysicalViewsIfNewer">
    <patch:attribute name="value" value="true" role:require="Standalone" />
    <patch:attribute name="value" value="false" role:require="ContentManagement or ContentDelivery" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.