ASP.NET Core web application chooses whether to compile views when publishing

When we publish the ASP.NET Core web application, choose to publish as a file, and choose the file system as the publishing method


By default, the view files of Views will be compiled into dll, as shown in the figure:


The file ending with PrecompiledViews.dll is the view compilation file, and we can't see the Views folder

If there is a need to modify the content of the view frequently, this is very inconvenient


solution:

Open the .csproj project file with Notepad

By default this is


Now modify the red box part to:

<PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>

  </PropertyGroup>


This configuration <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>

Indicates whether to compile view files. By default, there is no such line, which is equivalent to true.

save and republish

Post completed dog, you can see



In this way, we can modify the view file.

Note: If you have previously published a compiled view file in the same path once, you need to delete the original published file completely. Otherwise, PrecompiledViews.dll will still exist, and the modification of the view will not take effect.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324627196&siteId=291194637