5 Fast .NET CLI Commands Every C# Developer Should Know
As a C# developer, you’re likely familiar with Visual Studio, VS Code, or even lighter editors like Writer. But as Tim Corey points out at 0:00 in his video, leveraging a few essential .NET CLI commands can significantly boost your productivity. Whether you’re working on a .NET Core project, an ASP.NET Core web application, or a console project, understanding how to use the command line interface (CLI) effectively allows you to build, run, and deploy your .NET Core applications with precision and speed.
Tim’s training focuses on a short, practical 10-minute guide to five commands every developer should know. Instead of explaining concepts in theory, he demonstrates them on a freshly created Blazor web app project running .NET 10, highlighting real-world usage of the .NET Core SDK in the project directory (0:33).
Introduction to .NET CLI and the .NET Command Line Interface
At the start of the video, Tim emphasizes that even if you prefer an IDE like Visual Studio, understanding the .NET command line interface (CLI) is crucial. A command line interface CLI allows you to interact with your .NET Core applications directly, without relying on the IDE. This is especially useful when you want to run launch commands, perform explicit compile, or work in a cross-platform tool environment using Windows, Mac, or Linux.
Tim also gives a quick bonus tip at 1:15: running
dotnet --infoThis command lists installed .NET SDK versions, runtime packages in the runtime package store, architecture, and other environment details. It confirms that the .NET Core CLI is installed and ready to use, which is essential before exploring further commands.
1. Build Your Project with dotnet build
The first command Tim explains is dotnet build. This build command compiles your source code into DLL files in the output directory, typically under bin/Debug/net10/ or bin/Release/net10/. Tim demonstrates clearing the bin directory to remove previously compiled files, ensuring a clean build.
dotnet buildTim explains that this command creates the compiled output based on the configuration file and project template, whether it’s a console application, a class library, or an ASP.NET Core application. The build command is essential because it ensures your .NET Core CLI knows exactly what to compile and what specified files to include.
Using the build command is also a prerequisite for more advanced CLI commands like dotnet run or dotnet publish. Tim emphasizes that although Visual Studio handles builds automatically, knowing the explicit compile option with dotnet build helps in CI/CD pipelines or core command line workflows.
2. Run Your Application with dotnet run
Tim’s second command is dotnet run, a run command that builds and executes your .NET Core application in one step. Unlike dotnet build, which only compiles, **dotnet run executes the application in the current terminal or command prompt.
dotnet runUsing his Blazor web app, Tim demonstrates that dotnet run launches the application based on the launchSettings.json configuration file. The default URL and HTTP port are automatically selected. He edits the homepage using Notepad, and notes that updates don’t reflect until rerunning dotnet run (5:02).
This command is especially helpful for testing console applications, ASP.NET Core web apps, or even class library projects that reference other DLL files using dotnet add reference. For developers running unit tests in .NET Core, combining dotnet build with dotnet run ensures the specified assemblies are ready for the test runner.
3. Hot Reload with dotnet watch
To eliminate the need to restart your app after each change, Tim introduces dotnet watch, a file watcher CLI command that enables hot reload (5:44).
dotnet watchThis CLI command line interface monitors specified files in your project directory and automatically applies changes to the running application. Tim edits the homepage again, changing text from “Hello YouTube” back to “Hello World,” and the browser updates in real-time without restarting.
The file watcher feature is invaluable for cross-platform development, allowing .NET Core developers to work in lightweight editors like Notepad while maintaining the hot reload experience typically available only in Visual Studio or VS Code.
4. Clean Your Project with dotnet clean
Sometimes .NET projects can have leftover compiled files that cause errors or inconsistencies. Tim’s fourth command, dotnet clean, removes all files in the output directory and intermediate folders, such as bin/ and obj/ (7:06).
dotnet cleanAfter running this command, subsequent builds are performed from scratch, ensuring no DLL files or local NuGet resources interfere. Tim demonstrates that dotnet clean is particularly helpful when dealing with solution files that contain multiple .NET Core projects or class library projects with nuget packages.
This command ensures a fresh start for running unit tests with dotnet test or for preparing the project for deployment.
5. Publish Your Project with dotnet publish
Finally, Tim introduces dotnet publish, which prepares your .NET Core application for deployment on a hosting system like IIS, Azure, or other environments.
dotnet publishThis CLI command compiles the project and places the published assets in the publish folder under bin/Release/net10/. The output includes all specified assemblies, runtime packages, and necessary development certificates for hosting. Tim emphasizes that this command works for all .NET Core projects, including console applications, ASP.NET Core applications, and class libraries (8:18).
dotnet publish is also useful when combined with dotnet pack to create NuGet packages, making your code reusable across multiple .NET Core solutions.
Additional Tips and Notes
Tim highlights that mastering these five .NET Core CLI commands—dotnet build, dotnet run, dotnet watch, dotnet clean, and dotnet publish—covers roughly 85% of daily tasks in .NET Core development (9:01). He also mentions other command options and more detailed documentation online if you want to explore advanced flags, unit test runners, or custom project templates.
For new projects, developers can use dotnet new console, dotnet new class library, or other specified templates to quickly generate a .NET Core console application or ASP.NET Core project. Additionally, dotnet restore helps restore local NuGet resources and specified assemblies before building.
These commands are cross-platform, meaning the same CLI command line interface works on Windows, Mac, and Linux. They are also compatible with project templates, solution files, console applications, class library projects, and model-view-controller applications, making them versatile for almost all .NET Core projects.
Summary
Here’s a quick recap of the five essential .NET Core CLI commands Tim Corey recommends:
dotnet build – Explicitly compiles your project into DLL files in the output directory.
dotnet run – Builds and executes the .NET Core application immediately.
dotnet watch – Enables hot reload via a file watcher to automatically reflect changes.
dotnet clean – Removes all compiled files and intermediate folders for a fresh build.
- dotnet publish – Prepares a fully published .NET Core application for deployment on any hosting system.
These commands empower developers to manage .NET Core projects, solution files, and console projects efficiently using the .NET CLI without relying entirely on an IDE. By incorporating them into your workflow, you can quickly build, run, test, and deploy your .NET Core applications with confidence.

