News

Hot Reload Hits .NET (Kinda)

Much-requested and long-awaited Hot Reload functionality has hit .NET, supported in an early, incomplete form in the new Visual Studio 2019 version 16.11 (Preview 1).

Announced at the beginning of Microsoft's Build 2021 developer conference, Hot Reload has been a longstanding feature for projects like Blazor and Xamarin, coming late for the latter, after other dev frameworks like Flutter and React Native.

Hot Reload will eventually enable developers to make code changes while debugging that are instantly reflected in a running app without need of a restart, as part of a "Hot Reload Everywhere" push.

Today (May 25), Hot Reload for .NET proper was announced. "With Hot Reload you can now modify your apps managed source code while the application is running, without the need to manually pause or hit a breakpoint. Simply make a supported change while your app is running and in our new Visual Studio experience use the 'apply code changes' button to apply your edits."

In addition to being supported in VS 2019 v16.11 (Preview 1), it can be implemented with the dotnet watch command-line tool (with this reporter actually getting it to work last month with .NET 6 Preview 3).

Blazor Hot Reload in Animated Action
[Click on image for larger, animated GIF view.] Blazor Hot Reload in Animated Action (source: Microsoft).

Here's how it looks now:

Blazor Hot Reload in Animated Action
[Click on image for larger, animated GIF view.] New Hot Reload in Animated Action (source: Microsoft).

However, as noted, full functionality won't come until .NET 6 (coming in November) and Visual Studio 2022, of which we received a sneak peek last month, but for which we are still awaiting the first preview, coming this summer.

"With today's release this is just a preview of our full vision of Hot Reload for .NET developers," Microsoft said. "While some capability is being made available in early .NET 6 previews and in Visual Studio 2019, for the full power of this feature we are targeting .NET 6 (and future releases of .NET) and Visual Studio 2022 as the set of frameworks and tooling that will have the most complete and optimized experience."

For now, developers can expect some glitches and incomplete support and documentation. For example, Microsoft said it's still working to document what types of edits are supported.

Eventually, though, Microsoft said the final product's features will include:

  • .NET Multi-platform App UI (.NET MAUI): With .NET 6 Preview 4 developers building .NET MAUI applications can now use .NET Hot Reload with projects targeting WinUI 3. In future releases we're bringing .NET Hot Reload support to iOS, Android, and Mac Catalyst scenarios.
  • Razor Pages: In future releases Hot Reload and Edit and Continue (EnC) will be supported for editing Razor for websites or Blazor apps targeting .NET 6 or higher
  • No Debugger Required in Visual Studio: In future release of Visual Studio 2022 we are working to add support to use Hot Reload without needing the debugger, this means developers will be able to launch their apps using CTRL-F5 and still use Hot Reload to patch their running app
  • Reducing the number of unsupported changes: In future releases of Visual Studio 2022 and .NET 6+ we're planning work across multiple teams that will reduce the number of unsupported edits at runtime
  • Optimizing frameworks to work best with Hot Reload: In .NET 6 we're investigating how certain frameworks can be improved to better support Hot Reload. Examples of this in the future will include improvements to ASP.NET Core, .NET MAUI and other frameworks where tweaks and optimization will make Hot Reload changes more useful in more situations.
  • At this point, you can implement the prerequisite tooling and get started, with this caveat: "In this early preview release, we want to acknowledge that there will be bugs. Sometimes if you try to apply a change it might silently fail, or your app might crash, etc. If you do encounter any problems, please take a moment to report issues to us, as only with your feedback can we ensure that critical problems are resolved, and future decisions are prioritized based on your input."

    About the Author

    David Ramel is an editor and writer at Converge 360.

    comments powered by Disqus

    Featured

    • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

      The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

    • Diving Deep into .NET MAUI

      Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

    • Copilot AI Boosts Abound in New VS Code v1.96

      Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

    • AdaBoost Regression Using C#

      Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

    • Versioning and Documenting ASP.NET Core Services

      Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

    Subscribe on YouTube