As one is probably used from Javascript development, whenever one saves a file, a separately started background process immediately rebuilds as much as is required, and refreshes a browser window, reloads a service or anything else.
Apparently, this is a feature for Asp.Net as well, and has been for quite some time. With .Net 5, it is even more comfortable, as it can be handled fully through the command that launches the Kestrel server.
Previously, I used this command to start:
dotnet run --project GoodNight.Service.Api
supplies the dotnet
command, which represents the auto-rebuilding behaviour. It wants as arguments the watch
dotnet
command that should be supervised and restarted as required. For running the server, use this command:
dotnet watch --project GoodNight.Service.Api run
Observe that the run
command as moved behind the --project
flag: watch wants the project setting for itself, and will not launch without it. Luckily, it passes it on onto the child command.