Skip to content
Latchkey

dotnet run: Build and Run a Project

dotnet run builds the project in the current directory and runs the resulting executable, forwarding any arguments after a double dash.

run is convenient for smoke tests and tools in CI. The key is separating dotnet flags from the arguments your program should receive.

What it does

dotnet run compiles the project (unless --no-build) and launches the output executable. Arguments after -- are passed to your application rather than interpreted by the CLI.

Common usage

Terminal
dotnet run
dotnet run --project src/Tool/Tool.csproj
dotnet run -c Release --no-build -- --input data.json --verbose

Options

FlagWhat it does
--project <path>Project to run (defaults to the current directory)
-c, --configuration <name>Configuration to build and run
--no-buildRun without building (build in a prior step)
--no-restoreSkip the implicit restore
--Everything after this is passed to your program
--framework <tfm>Run a specific target framework

In CI

Put -- before your program arguments or the CLI will try to parse them as its own flags. For a long-running app (a server) dotnet run blocks the step; use it only for short tools or background it and capture the PID. The job inherits your program exit code, so a non-zero exit fails the step as expected.

Common errors in CI

MSB1009 ("Project file does not exist") means --project points at a wrong path. "Couldn't find a project to run" means the working directory has no project and you did not pass --project. If your program arguments are being read by dotnet instead of your app, you forgot the -- separator.

Related guides

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