I am developing a website in asp.net mvc with NET 6 and when I deploy I cannot find anymore the cshtml pages, but a lot of folders, dll and an .exe.
The problem is that it looks like I need to update all the website each time I modify one single page.
Is there a way to put online only the modified page cshtml without deploying the entire website?
1. You need add Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
package.
2. You also need Copy the cshtml when you deploy.
So my .csproj file like:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.2" />
</ItemGroup>
<ItemGroup>
<ViewFiles Include="$(ProjectDir)\Views\**\*.cshtml" />
</ItemGroup>
<Target Name="CopyViewFilesAfterPublish" AfterTargets="Publish">
<Copy SourceFiles="@(ViewFiles)"
DestinationFolder="$(PublishDir)\Views\%(RecursiveDir)"
/>
</Target>
</Project>
Test Result: