liveBook · Manning

Code reloading

As explained in .NET MAUI in Action

Hot reload on file save is an automatic hot-reload mode that applies supported changes when a source file is saved.

Code reloading keeps a .NET MAUI app running while supported changes appear in real time. Hot Reload on File Save applies those changes automatically whenever you save a file, making the edit-run-check loop faster. section 2.4 section 2.4.1

Use the workflow like this:

  • Run the .NET MAUI app from Visual Studio for Windows or Visual Studio for Mac. section 2.4 section 2.4.2
  • Edit a supported value in MainPage.xaml, such as text or a layout property, and save the file. section 2.4.1 section 2.4.2
  • Enable Hot Reload on File Save from the Hot Reload button’s drop-down to apply supported edits without manually triggering reload. section 2.4.1
  • Rebuild or restart when the change adds or removes classes, methods, or resources such as images. section 2.4.1 section 2.4.2

Changing an app while it runs

Replace “Hello, World!” with “Aloha, World!” in the running app’s XAML and save. The updated text appears without restarting. Replace the Dotnet Bot image as well, but expect a rebuild or restart because image resources cannot be changed by Hot Reload. section 2.4 section 2.4.2

Figure 2.18 The Hot Reload button in Visual Studio

The Visual Studio Hot Reload button provides the entry point for manually applying changes and enabling file-save reload. section 2.4.1

How .NET MAUI in Action covers it

How deep it goes
Explains file-save activation, supported edits, and rebuild limits caused by immutable CLR metadata and resources.
Examples
Uses greeting edits, XAML layout changes, and a custom Dotnet Bot image to contrast reloadable and rebuild-required changes.
What it assumes
Assumes a running .NET MAUI app and basic XAML editing while introducing the reload workflow from zero.
What you can do after
Apply it via Visual Studio to iterate on running .NET MAUI interfaces without restarting after every supported edit.
How it connects
Connects .NET MAUI with Visual Studio, XAML, the .NET CLI, dotnet watch run, and CLR compilation.

Also explained in

Compare how 4 books explain code reloading →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.