CLI Tools & Commands
Master the .NET Core CLI tools for project management, building, and deployment. This is a foundational concept in cross-platform .NET development that professional developers rely on daily. The explanations below are written to be beginner-friendly while covering the depth and nuance that comes from real-world .NET Core experience. Take your time with each section and practice the examples
Essential .NET CLI Commands
The .NET CLI is a cross-platform toolchain for developing .NET applications. It provides commands for creating, building, running, and publishing applications.. This is an essential concept that every .NET Core developer must understand thoroughly. In professional development environments, getting this right can mean the difference between code that works reliably and code that breaks in production. The following sections break this down into clear, digestible pieces with practical examples you can try immediately
Project Management Commands
# Create a new project
dotnet new console -n MyApp
dotnet new webapi -n MyWebApi
dotnet new classlib -n MyLibrary
# Add packages
dotnet add package Newtonsoft.Json
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
# Remove packages
dotnet remove package Newtonsoft.Json
# List installed packages
dotnet list package
# Restore dependencies
dotnet restore
# Build the project
dotnet build
# Run the project
dotnet run
# Publish the project
dotnet publish -c Release -r win-x64 --self-contained trueSolution Management
# Create a solution
dotnet new sln -n MySolution
# Add projects to solution
dotnet sln add MyApp/MyApp.csproj
dotnet sln add MyLibrary/MyLibrary.csproj
# Remove project from solution
dotnet sln remove MyApp/MyApp.csproj
# List solution projects
dotnet sln list
# Build entire solution
dotnet build MySolution.sln