Since the virtual path name is relative, whether the ~/Views/Home/Index.cshtml view resides in the ASP.NET MVC application or the class library project, its virtual path is the same.
The following shows the first few lines of the sample view Index.cshtml that includes that The PrecompiledMvcViewEngine doesn’t look at physical files it looks for the that the Razor Single File Generator adds to every view that it generates that includes the view’s relative file path. Note: But how did the PrecompiledMvcViewEngine know which view to render? Though it may be surprising, PrecompiledMvcViewEngine still relies on the ASP.NET MVC Views folder convention, using relative file paths to locate the views.
But how did the PrecompiledMvcViewEngine know which view to render ASP.NET MVC now executes the precompiled Index.cshtml file from the class library, not caring that the file did not exist in its local ~/Views folder.