.NET Hot Reload in Visual Studio Code

visibility 3,322 event 2022-03-26 access_time 9 months ago language English
more_vert

Hot Reload is a very useful feature that is introduced in Visual Studio to enable developers to save the time to restart applications after live code editing. It can improve your productivity when developing solutions in Visual Studio. This page shows you how to do that in Visual Studio Code.

Create launch profile with hot reload

In .NET launchable projects like console, website and others, create launch profile in folder Properties\launchSettings.json. You can add profiles in "profiles" property in the document:

    "profiles": {
        "hotreloadprofile": {
            "commandName": "Project",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "Key": "Value"
            },
            "applicationUrl": "https://localhost:5001;http://localhost:5000",
            "hotReloadProfile": "aspnetcore"
        } }

Remembers to add hotReloadProfile property accordingly. 

Depends on the project type, the possible values are:

  • Blazor WebAssembly: blazorwasm
  • ASP.NET Core application: aspnetcore

Launch application with hot reload

Now you can use the following command line to launch the application with hot reload:

dotnet watch run --launch-profile hotreloadprofile

 

copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts