⚙️ Using the .NET Core CLI

.NET Core CLI allows you to interact with the .NET Core runtime as well as manage your .NET Core solutions and projects (read more here)

The following is a brief overview of some of the more important and most likely daily commands that you want to be familiar with.

Viewing list of templates

Display a list of all solution and project templates that are available to generate a new solution or project.

dotnet new --list

Retrieve all dependencies of each project in a solution

dotnet restore

more on restoring dependencies

Creating a solution

# Basic invocation
dotnet sln new --name [name-of-solution] --output [path-to-new-solution]

# Example:
dotnet new sln --name NeverendingTeaShop --output NeverendingTeaShop/

Creating a project

# Basic invocation
dotnet new [template] --name [name-of-project] --output [path-to-new-project]

# Example:
dotnet new webapi --name NeverendingTeaShop.API --output ./src/NeverendingTeaShop.API
dotnet new xunit --name NeverendingTeaShop.API.Tests --output ./tests/NeverendingTeaShop.API.Tests

Run a deployable project

# Basic invocation
dotnet run [path-to-csproj]

# Example
dotnet run NeverendingTeaShop/src/NeverendingTeaShop.API

Live reload changes when developing

# Watch a running application locally
dotnet watch run

# Watch tests
dotnet watch test

Adding a NuGET package to a project

An example of adding Serilog nuget to a project

# If inside the project directory
dotnet add package Serilog

# If in root directory of a multi-project solution
dotnet add <path-to-project> package Serilog