If you want to use ASP.NET 2.x or 3.x you need to change it a bit.
-
The watch tool is a global tool now and you don’t need to add it as a reference any longer
-
The syntax is slightly different
"Watch": { "executablePath": "dotnet.exe", "workingDirectory": "$(ProjectDir)", "commandLineArgs": "watch run", "launchBrowser": true, "launchUrl": "http://localhost:5000/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }
For .Net 5 & 6
In VisualStudio 2019
- Go to Tools > ⚙ Options > Projects and Solutions > ASP .NET Core
- Select Auto build and refresh browser after saving changes in Auto build and refresh option
- Press Ctrl + F5 (Start Without Debugging) IMPORTANT: Only works if run without debbuging
Otherwise add this to your launchSettings.json
:
{
"iisSettings": {
...
},
"profiles": {
... ,
"Watch": {
"commandName": "Executable",
"executablePath": "dotnet.exe",
"workingDirectory": "$(ProjectDir)",
"commandLineArgs": "watch run"
}
}
}
The automatically generated profile
with "commandName":"Project"
has all the other properties needed: launchBrowser
, applicationUrl
, environmentVariables
, dotnetRunMessages
and hotReloadProfile
. Any modifications should be made there.
Corresponding Blog-Post from Juan Cruz Fiant: https://dev.to/juxant/auto-refresh-with-dotnet-watch-for-asp-net-core-projects-20no