Skip to content
Latchkey

dotnet watch: Re-run on File Changes

dotnet watch monitors source files and re-runs the underlying command (run, test, build) whenever they change.

watch is a developer-loop tool. It almost never belongs in CI, but knowing why keeps it out of pipelines where it would hang.

What it does

dotnet watch wraps another dotnet command and watches the project files. On a change it re-runs that command, and for run it can apply Hot Reload without a full restart. It is a long-running, interactive process by design.

Common usage

Terminal
dotnet watch run
dotnet watch test
dotnet watch --no-hot-reload run
dotnet watch run --project src/Api

Options

FlagWhat it does
run / test / buildThe dotnet command to re-run on change
--no-hot-reloadRestart the process instead of applying Hot Reload
--project <path>Project to watch
--Pass the rest of the arguments to the inner command

In CI

Do not use dotnet watch in CI: it never exits on its own, so the step blocks until the job times out. Use plain dotnet test or dotnet run for a one-shot run. watch belongs only in local development or a container you intend to keep alive.

Common errors in CI

The usual "error" is no error at all: the step hangs and the job hits its timeout because watch waits for changes forever. If you see "watch : Started" in CI logs followed by silence, replace dotnet watch test with dotnet test. On a headless runner Hot Reload may log "Unable to apply hot reload" warnings that are harmless but noisy; --no-hot-reload quiets them.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →