.NET CLI

Updated: 08 December 2024

new

Create a new .NET project based on the console template.

dotnet new console --name our_project

run

Build and test the Release version of a console application

dotnet run --configuration Release

test

Run the tests in the project in the current directory

dotnet test

clean

Clean up the output of the previous build. Both intermediate (obj) and final output (bin) folders are cleaned.

dotnet clean

restore

Restores the dependencies and tools for a project i.e. external libraries in NuGet packages. All dependencies become available in a local cache and can be used by the .NET CLI to build and run the application.

dotnet restore

dotnet

List installed Software Developer Kits

dotnet --list-sdks

List installed runtimes

dotnet --list-runtimes

build

Build a project and its dependencies using Release configuration

dotnet build --configuration Release

Build the project and its dependencies into a set of binaries. The binaries include the project’s code in Intermediate Language (IL) files with a .dll extension.

dotnet build

publish

Publishes the application and its dependencies to a folder for deployment to a hosting system.

dotnet publish

Attempt to target Linux (not tested)

dotnet publish --configuration release --runtime linux-x64 --self-contained

Attempt to target Linux (not tested)

dotnet publish --runtime linux-x64 -p:PublishSingleFile=true --self-contained false

Leave a comment