How to enable Hot Reload in ASP.NET Core 7 web site project

I’m looking to enable Hot Reload to hopefully allow edits to *.cs and/or *.cshtml files without restarting debug cycle.

My original configurations in tasks.json and launch.json are as follows and everything worked (without Hot Reload)…after the site built and started, it found the log entry in terminal and launched the site with the uriFormat argument in a new/clean Chrome instance and all debugging working as expected.

Original tasks.json:

{
    "label": "debug",
    "hide": true,
    "command": "dotnet",
    "type": "process",
    "presentation": {
        "clear": true
    },
    "args": [
        "build", "${input:projectFile}",
        "/property:GenerateFullPaths=true",
        "/consoleloggerparameters:NoSummary"
    ],
    "problemMatcher": "$msCompile"
},

Original launch.json:

{
    "name": "Site",
    "presentation": {
        "order": 1,
        "group": "1. L@W Connect"
    },
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "debug",
    "logging": {
        "moduleLoad": false
    },
    "program": "${workspaceFolder}/bin/Debug/net7.0/Nexgen.dll",
    "args": [],
    "cwd": "${workspaceFolder}",
    "stopAtEntry": false,            
    "serverReadyAction": {
        "action": "debugWithChrome",                              
        "pattern": "\bNow listening on:\s+(https?://\S+)",
        "uriFormat": "%s/app/channel-home?aws=1&lp=0&datasource=1&showinspector=1&apidebug=ApiProxy_,RBLe_,DocGen_&rblcache=1&tracekatapp=0&sitekey=GOLD",
        "killOnServerStop": true
    },
    "sourceFileMap": {
        "/Views": "${workspaceFolder}/Views"
    },
    "launchSettingsProfile": "Site"            
},

I modified these files (with advice from Github Copilot) with the following.

New tasks.json:

  1. New label
  2. New args
  3. Added isBackground
  4. New presentation settings
{
    "label": "watch",
    "command": "dotnet",
    "type": "process",
    "args": [
        "watch",
        "run",
        "--project",
        "${input:projectFile}"
    ],
    "problemMatcher": "$msCompile",
    "isBackground": true,
    "presentation": {
        "reveal": "always",
        "panel": "shared"
    }
}

New launch.json:

  1. serverReadyAction.action and serverReadyAction.uriFormat changed
  2. Removed launchSettingsProfile (which is used by devs in Visual Studio proper)
{
    "name": "Site",
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "watch",
    "program": "${workspaceFolder}/bin/Debug/net7.0/Nexgen.dll",
    "args": [],
    "cwd": "${workspaceFolder}",
    "stopAtEntry": false,
    "serverReadyAction": {
        "action": "openExternally",
        "pattern": "Now listening on: (https?://\S+)",
        "uriFormat": "%s"
    },
    "env": {
        "ASPNETCORE_ENVIRONMENT": "Development"
    },
    "sourceFileMap": {
        "/Views": "${workspaceFolder}/Views"
    }
},

When I try to launch with updated settings, I get a dialog stating (even though there is a problemMatcher defined):

The task ‘watch’ has not exited and doesn’t have a ‘problemMatcher’ defined. Make sure to define a problem matcher for watch tasks.

[Debug Anyway] [Configure Task] [Cancel]

In the terminal window, my logging is as follows:

dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.  💡 Press "Ctrl + R" to restart.
dotnet watch 🔧 Building...
  Determining projects to restore...
  All projects are up-to-date for restore.
  Camelot.Abstractions.Api.Contracts.WebService.Proxy -> c:BTRCamelotAbstractionsApi.ContractsWebService.ProxysrcbinDebugnet7.0KAT.Camelot.Abstractions.Api.Contracts.WebService.Proxy.dll
  Camelot.Abstractions.Api.Contracts.DataLocker -> c:BTRCamelotAbstractionsApi.ContractsDataLockersrcbinDebugnet7.0KAT.Camelot.Abstractions.Api.Contracts.DataLocker.dll
  Camelot.Abstractions.RBLe -> c:BTRCamelotAbstractionsRBLebinDebugnet7.0KAT.Camelot.Abstractions.RBLe.dll
  Camelot.Abstractions.Api.Contracts.RBLe -> c:BTRCamelotAbstractionsApi.ContractsRBLesrcbinDebugnet7.0KAT.Camelot.Abstractions.Api.Contracts.RBLe.dll 
  Camelot.Domain -> c:BTRCamelotCoreDomainsrcbinDebugnet7.0KAT.Camelot.Domain.dll
  Camelot.Infrastructure -> c:BTRCamelotCoreInfrastructuresrcbinDebugnet7.0KAT.Camelot.Infrastructure.dll
  Camelot.Telemetry -> c:BTRCamelotCoreTelemetrysrcbinDebugnet7.0KAT.Camelot.Telemetry.dll
  Camelot.Data -> c:BTRCamelotCoreDatasrcbinDebugnet7.0KAT.Camelot.Data.dll
  Camelot.Domain.Web -> c:BTRCamelotCoreDomain.WebsrcbinDebugnet7.0KAT.Camelot.Domain.Web.dll
  Camelot.Telemetry.Web -> c:BTRCamelotCoreTelemetry.WebsrcbinDebugnet7.0KAT.Camelot.Telemetry.Web.dll
  Camelot.Infrastructure.Web -> c:BTRCamelotCoreInfrastructure.WebsrcbinDebugnet7.0KAT.Camelot.Infrastructure.Web.dll
  Nexgen -> c:BTRCamelotWebsitesNexgenbinDebugnet7.0Nexgen.dll
dotnet watch 🚀 Started
[22:24:28 INF] Now listening on: https://localhost:7058 <s:Microsoft.Hosting.Lifetime>
dotnet watch 🌐 Unable to launch the browser. Navigate to https://localhost:7058 <s:Microsoft.Hosting.Lifetime>
[22:24:28 INF] Application started. Press Ctrl+C to shut down. <s:Microsoft.Hosting.Lifetime>
[22:24:28 INF] Hosting environment: Development <s:Microsoft.Hosting.Lifetime>    
[22:24:28 INF] Content root path: c:BTRCamelotWebsitesNexgen <s:Microsoft.Hosting.Lifetime>

How can I enable Hot Reload?

2

In VS code you can open the terminal and run command “dotnet watch run” which will provide you similar functionality.

You can reference this issue: ASP.NET Core with VS Code, can’t run the application without debugging enabled

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật