LinuxCommandLibrary

dotnet-run

Run .NET applications from source code

TLDR

Run the project in the current directory

$ dotnet run
copy

Run a specific project
$ dotnet run --project [path/to/file.csproj]
copy

Run the project with specific arguments
$ dotnet run -- [arg1=foo arg2=bar ...]
copy

Run the project using a target framework moniker
$ dotnet run [[-f|--framework]] [net7.0]
copy

Specify architecture and OS, available since .NET 6 (Don't use --runtime with these options)
$ dotnet run [[-a|--arch]] [x86|x64|arm|arm64] --os [win|win7|osx|linux|ios|android]
copy

SYNOPSIS

dotnet run [OPTIONS] [-- application arguments]

PARAMETERS

-p|--project <PROJECT>
    Path to project file to run (defaults to current directory)

-c|--configuration <CONFIGURATION>
    Configuration: Debug, Release, or custom (default: Debug)

-f|--framework <FRAMEWORK>
    Target framework to run (e.g., net8.0)

--runtime <RUNTIME_IDENTIFIER>
    Target runtime (e.g., linux-x64)

--no-build
    Do not build the project before running

--no-restore
    Do not restore dependencies

-v|--verbosity <LEVEL>
    Set output verbosity: quiet|minimal|normal|detailed|diagnostic

--launch-profile <NAME>
    Name of launch profile from launchSettings.json

--interactive
    Enables interactive mode for restore/build

DESCRIPTION

The dotnet run command provides a convenient way to execute .NET console applications directly from source code. It automatically compiles the project if necessary (unless --no-build is specified) and launches the application. Ideal for development workflows, it supports specifying project files, configurations, frameworks, and runtime identifiers.

Key features include incremental builds for speed, integration with launch profiles from launchSettings.json, and passing arguments to the app. It restores dependencies if needed but skips this with --no-restore. Verbosity levels control output detail. Use -- to pass arguments directly to the application, distinguishing them from dotnet run options.

This command is part of the .NET SDK CLI, cross-platform including Linux, and essential for rapid iteration during app development. It detects the project file in the current directory or subdirectories by default.

CAVEATS

Requires .NET SDK installed; fails if no runnable project found; --no-build assumes prior build success; launch profiles Linux-specific may vary.

EXAMPLES

dotnet run
dotnet run --project /path/to/MyApp.csproj --configuration Release
dotnet run -- --help (passes --help to app)

HISTORY

Introduced in .NET Core 1.0 (2016) as part of cross-platform CLI; evolved with .NET 5+ unification, adding TFM support, launch profiles in .NET Core 2.1, and interactive restore in .NET 6+ for faster dev cycles.

SEE ALSO

dotnet build(1), dotnet restore(1), dotnet publish(1), dotnet watch(1)

Copied to clipboard