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/"> <sitecore> <mvc> <precompilation> <assemblies> <assemblyIdentity name="My.Project" /> <assemblyIdentity name="My.OtherProject" /> </assemblies> </precompilation> </mvc> </sitecore> </configuration>
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?
Current: [PageVirtualPath("~/Views/Feature/Renderings/Sample.cshtml")] Desired: [PageVirtualPath("~/Client/Views/Feature/Renderings/Sample.cshtml")]
Or have other suggestions on how this works?
Update: Ticket into Sitecore support for clarification, but in meantime ran a test by:
- removing our route modification override
- updated all view renderings by quick
ymlunicorn sync to set default path
- 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.
Sitecore.Mvcif you decompile it.
ViewLocationFormatsof the razor engine? If so, I would expect that it would just work as expected