Asp.NET Core Command Line
Dotnet CLI is a command line tool. It contains commands you can use to
1. Create a new project
2. Build a project
3. Run the project
4. Publish the project
5. Restore Nuget Packages
6. Migrate from one version to another version of .NET
Download & Installing dotnet cli
The Dot Net CLI is part of the .NET SDK. Hence install .NET SDK to install the .NET CLI.
The CLI installs side by side manner. We can install & use multiple versions of CLI Tools side by side.
Commonly used Commands
new- Creates a new project, configuration file, or solution based on the specified template.
restore- Restores the dependencies and tools of a project.
build- Builds a project and all of its dependencies.
publish- Packs the application and its dependencies into a folder for deployment to a hosting system.
run- Runs source code without any explicit compile or launch commands.
test- .NET test driver used to execute unit tests.
vstest- Runs tests from the specified files.
pack- Packs the code into a NuGet package.
migrate- Migrates a Preview 2 .NET Core project to a .NET Core SDK 1.0 project.
clean- Cleans the output of a project.
sln- Modifies a .NET Core solution file.
help- Shows more detailed documentation online for the specified command.
store- Stores the specified assemblies in the runtime package store.
Some of the key functionalities and tasks that the ASP.NET Core CLI supports:
Creating Projects: Using templates, you can use the CLI to create new ASP.NET Core projects. For example, you can create a new web application, a web API, a class library, and more.
Building Projects: The CLI allows you to build your projects using the dotnet build command. This compiles your code, resolves dependencies, and produces the output binaries.
Running Applications: You can execute your ASP.NET Core applications using the dotnet run command. This starts your application and hosts it on a local development server (usually Kestrel).
Publishing Applications: The dotnet publish command packages your application for deployment. It compiles the code, includes all required dependencies, and prepares the output for deployment to a server.
Adding Packages: The CLI supports adding NuGet packages to your project using the dotnet add package command.
Managing Dependencies: Using the CLI, you can manage package references, remove packages, and update package versions.
Database Migrations: For projects that use Entity Framework Core, the CLI can be used to manage database migrations and apply changes to the database schema.
Global Tools: The CLI allows you to install and manage global tools that provide additional functionality, like code analysis or project scaffolding.
Project Scaffolding: The CLI can generate code files and project structures based on templates.
Testing: You can run unit tests using the dotnet test command.
Code Generation: The CLI supports code generation for various parts of your application, such as controllers, views, and more.