With the C# Dev Kit extension installed in Visual Studio Code, the debugger allows you to apply C# code changes while debugging, this is what we have come to know as Hot Reload.

hotreload-toolbar

To get started with Hot Reload in VS Code you will need to update the csharp.experimental.debug.hotreload inUser settings (under File > Preferences > Settings). You can of course explicitly apply changes by clicking the fire icon (or pressing Ctrl-Shift-Enter), alternatively you can automatically apply changes when you save a file by setting the csharp.debug.hotReloadOnSave setting to true.

General limitations

As of the date of this writing there are a couple of important differences in the feature set compared to the Visual Studio:-

  • ASP.NET Core applications will not automatically refresh the browser after a change is made.
  • Code changes will only be applied while actively debugging.

Linux/macOS limitations

Multi OS support for VS Code is a real strength, however, Hot Reload on Linux/Mac needed additional runtime support which means that .NET 8+ is required for Hot Reload on these operating systems.

Project types that support Hot Reload on Linux/Mac include:

  • ASP.NET Core (.cs files only)
  • Console
  • Class Library
  • Test

Project types that do not support Hot Reload on Linux/Mac include:

  • Unity
  • Maui (coming soon)

For more details please check out the Hot Reload docs here.

paul-bulai-flame-unsplash

Photo by Paul Bulai on Unsplash



Comment Section

Comments are closed.