Aspnetcore: dotnet watch does not reload views on disk

Created on 8 Mar 2019  路  5Comments  路  Source: dotnet/aspnetcore

Describe the bug

When running 'dotnet watch run' on MacOSX views on disk doesn't get served when they are updated.

Have added this as suggested in other bug reports and stackoverflow replies without any luck.
I have no views compiled into a dll of any kind.

<PropertyGroup>
    <RazorCompileOnBuild>false</RazorCompileOnBuild>
    <RazorCompileOnPublish>false</RazorCompileOnPublish>
   <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>

To Reproduce

Steps to reproduce the behavior:

  1. Using ASP.NET Core 2.2.104 on MacOSX 10.12.6

Expected behavior

To be able to see the updated views without having to restart the process

area-mvc question

All 5 comments

Same on Windows. I have to restart the debugger each time I update a view or a razor page. It's really time consuming.

In ASP.NET Core 2.2, the default behavior of razor and views is that .cshtml should be re-compiled at runtime without restarting the process. MVC has its own file watcher on *.cshtml files and should be refreshing views when the .cshtml changes. For this reason, dotnet-watch does not restart when *.cshtml files change.

cc @mkArtakMSFT @pranavkm

Starting in 3.0, runtime compilation is not enabled by default and we compile views and pages as part of the normal build. We should update all of our auto-build experiences to build .cshtml and .razor files by default (tracked by this issue), and then have some way for runtime compilation to disable auto-build for .cshtml if runtime compilation is enabled (#9641).

@natemcmaster correctly pointed out this is an issue with 2.2. In 2.2, runtime compilation works in tandem with build time compilation and these changes should get picked. However, you could give the file watcher an additional nudge by setting DOTNET_USE_POLLING_FILE_WATCHER in case the dotnet file watcher is having trouble. See https://github.com/aspnet/Mvc/issues/7028#issuecomment-342217586.

One more thing, if you want to customize the behavior of dotnet-watch to include *.cshtml files, you can do that by customizing your project file. See https://docs.microsoft.com/en-us/aspnet/core/tutorials/dotnet-watch?view=aspnetcore-2.2#customize-files-list-to-watch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danroth27 picture danroth27  路  79Comments

moodya picture moodya  路  153Comments

kevinchalet picture kevinchalet  路  761Comments

MaximRouiller picture MaximRouiller  路  338Comments

KerolosMalak picture KerolosMalak  路  269Comments