title: ASP.NET Core: how to override view from dll
body: <p>Given a library referenced in a project. That library has precompiled views (see this <a href="https://dzone.com/articles/self-contained-ui-running-one-aspnet-core-mvc-site" rel="nofollow noreferrer">post</a> how to achieve it). So the lib has ABC.dll and ABC.PrecompiledViews.dll assemblies.</p>
  
  <p>There's a view in library inside <code>/Views/Shared/Index.cshtml</code>. And a controler which returns it.</p>
  
  <p>Then I have an application references the library (both assemblies). MVC discovers and returns that Index view in runtime.</p>
  
  <p>Now I create a view inside application in <code>Views/Shared/Index.cshtml</code>. So its relative name is the same as in referenced view. By I doing this I mean that I want to override the view from the library.</p>
  
  <p>When application is started from VS (Ctrl-F5) it works but the view in application is ignored.
  When application is published (<code>dotnet publish</code>) then the application fails on start with the following error:</p>
  
  <pre><code>InvalidOperationException: The following precompiled view paths differ only in case, which is not supported:
  /Views/Shared/Index.cshtml
  /Views/Shared/Index.cshtml
  </code></pre>
  
  <p>Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler..ctor(IFileProvider fileProvider, RazorTemplateEngine templateEngine, CSharpCompiler csharpCompiler, Action compilationCallback, IList precompiledViews, ILogger logger)</p>
  
  <p>Besides the problem that the view is ignored when I run from VS it's meaningful behavior. The app has two similar view and can't understand which one to choose.</p>
  
  <p>So the question is how to force MVC to use a particular view (from app instead of from lib)?</p>
  
  <p>There's a method to separate views with same relative names when they are belong to different controllers. Here's nice discussion - <a href="https://stackoverflow.com/questions/34306891/restrict-route-to-controller-namespace-in-asp-net-core/34309154">Restrict route to controller namespace in ASP.NET Core</a>
  But my case is a bit different.</p>