Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically reload .NET Core project in Visual Studio 2019

Tags:

I tried to automatically reload ASP.NET Core project as I do using Angular with Node or NPM.

When I change the code of the .NET Core project and save, I want the web page to be automatically refreshed in the web browser.

like image 943
Akash Limbani Avatar asked Nov 25 '19 07:11

Akash Limbani


People also ask

How do I enable hot reload in Visual Studio?

On Windows, check the Enable XAML Hot Reload checkbox (and the required platforms) at Tools > Options > Debugging > Hot Reload. In earlier versions of Visual Studio 2019, the checkbox is at Tools > Options > Xamarin > Hot Reload.

Is Hot reload available in VS 2019?

Today, we are excited to introduce you to the availability of the . NET Hot Reload experience in Visual Studio 2019 version 16.11 (Preview 1) and through the dotnet watch command-line tooling in .

How do I turn off hot reload in Visual Studio?

We've changed these settings in the next preview so that hot reload is controlled solely from the Tools\Options\Debugger\Enc&Hot Reload option page, and these settings will only apply when you turn off Hot Reload for Ctrl+F5.


1 Answers

run this command in project console

dotnet watch run 

same works for visual studio code

From Develop ASP.NET Core apps using a file watcher (for 3.0)

dotnet watch is a tool that runs a .NET Core CLI command when source files change. For example, a file change can trigger compilation, test execution, or deployment.

The link above contains a tutorial with two sample projects:

  1. WebApp (an ASP.NET Core web API) and
  2. WebAppTests (unit tests for the web API).

Alternatively, you can also this nuget package for runtime compilation.

like image 159
Amir Dora. Avatar answered Oct 29 '22 22:10

Amir Dora.