LinuxCommandLibrary

dotnet

Run, build, and manage .NET applications

TLDR

Initialize a new .NET project

$ dotnet new [template_short_name]
copy

Restore NuGet packages
$ dotnet restore
copy

Build and execute the .NET project in the current directory
$ dotnet run
copy

Run a packaged dotnet application (only needs the runtime, the rest of the commands require the .NET Core SDK installed)
$ dotnet [path/to/application.dll]
copy

SYNOPSIS

dotnet [options]
dotnet <path-to-application>
dotnet [-p|--project <PROJECT>] [[-c|--configuration] [<CONFIGURATION>]] [[-f|--framework] [<FRAMEWORK>]] <COMMAND> [<ARGUMENTS>]

PARAMETERS

-p|--project <PROJECT>
    Path to project or solution. Auto-detects if omitted.

-c|--configuration <CONFIGURATION>
    Build configuration (Debug/Release). Defaults to Debug.

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

--verbosity <LEVEL>
    MSBuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], diag[nostic]. Defaults to minimal.

--version
    Display .NET SDK version.

-h|--help
    Show command help.

--info
    Display .NET installation info.

--list-sdks
    List all installed .NET SDKs.

--list-runtimes
    List all installed .NET runtimes.

--diagnostics
    Enable diagnostic mode for troubleshooting.

@<file>
    Read arguments from response file.

DESCRIPTION

The dotnet command serves as the primary entry point for the .NET command-line interface (CLI), a powerful toolset for developing, building, testing, and deploying .NET applications on Linux and other platforms.

It enables developers to manage projects efficiently without a full IDE, supporting C#, F#, and Visual Basic. Core workflows include creating solutions with dotnet new, restoring NuGet packages via dotnet restore, compiling code with dotnet build, executing apps using dotnet run, running tests with dotnet test, and publishing self-contained executables or framework-dependent deployments with dotnet publish.

The CLI is lightweight, scriptable, and integrates seamlessly into CI/CD pipelines like GitHub Actions or Jenkins. It auto-detects projects in the current directory but allows targeting specific ones via options. Global options control verbosity, configuration (Debug/Release), and framework targeting (e.g., net8.0). On Linux, it's part of the .NET SDK, installable via apt, dnf, or tarballs from Microsoft.

Extensible with global tools (dotnet tool) and templates, it supports modern .NET features like AOT compilation and cloud-native apps.

CAVEATS

Requires .NET SDK in PATH; some subcommands need workloads (e.g., dotnet workload install). Project must have .csproj/.fsproj. Verbose output can be noisy.

COMMON SUBCOMMANDS

new (create projects), restore (NuGet deps), build (compile), run (execute), test (unit tests), publish (deploy), pack (NuGet pkgs), tool (global tools). Use dotnet --help for full list.

DIRECT APP EXECUTION

Run published apps directly: dotnet app.dll or ./MyApp (self-contained).

HISTORY

Introduced with .NET Core 1.0 (June 2016) for cross-platform dev. Evolved through .NET 5+ unification; .NET 8 (2023) adds AOT, Native AOT, and better Linux perf.

SEE ALSO

msbuild(1), nuget(1)

Copied to clipboard