Hot Reloading During Development

Learn about Hot reload, which allows real-time code changes without app restarting, aiding rapid development and bug fixing.

Hot reload is a feature that allows a developer to apply changes to code while the app is running and immediately see the effect. This is great for fixing bugs quickly. Hot reload is also known as “Edit and Continue.” A list of the types of changes that we can make that support Hot reload can be read.

Hot reload using the command line

Just before the release of .NET 6, a high-level Microsoft team member caused controversy by attempting to make the feature Visual Studio-only. Luckily, the open-source contingent within Microsoft successfully had the decision overturned. Hot reload remains available using the command-line tool as well. Let’s see it in action:

Step 1: Use your preferred coding tool to add a new “Console App or console project” named Hot Reloading to the Chapter04 workspace/solution.

  • In Visual Studio Code, select HotReloading as the active OmniSharp project. When you see the pop-up warning message that required assets are missing, click “Yes” to add them.

Step 2: Modify HotReloading.csproj to import System.Console statically for all code files.

Step 3: In Program.cs, delete the existing statements, and then write a message to the console output every two seconds, as shown in the following code:

Get hands-on with 1400+ tech skills courses.