Monthly Archives

One Article

Visual Studio Tips

Tips for Productivity in .NET Core

Posted by matteskolin on
  1. Enable Runtime Compilation for Razor Pages
    In .NET 5, changing the cshtml file while the application is running does not take effect until the application is restarted. This slows the edit-compile-debug cycle if you need to constantly recompile the entire app while working on a cshtml such as when building the CSS styles.

    Runtime Compilation will enable you to edit the cshtml and see the changes by refreshing the browser window.

    To Enable, add the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet Package and then add this to your ConfigureServices method.
 public void ConfigureServices(IServiceCollection services)
 {
      services.AddMvc().AddRazorRuntimeCompilation();
 }

Related Stack Overflow https://stackoverflow.com/questions/54600273/net-core-3-0-razor-views-dont-automatically-recompile-on-change

2. Learn To use the .NET CLI

This Command line interface provides an efficient way to access to the .NET SDK. I especially like the dotnet new command when I want to test a new idea or investigate a bug in a fresh project. The CLI can also be used to manage nuget packages, clean, build, run, and test your projects and solutions.