Create a new ASP.NET Core project using the dotnet new command.
Example
dotnet new webapi -n MyApi
Restore
Restore the project's dependencies using the dotnet restore command. This ensures that all required packages are downloaded and available for building the project:
Example
dotnet restore
Build
Build the ASP.NET Core project using the dotnet build command. This compiles the source code and generates the necessary binaries:
Example
dotnet build
Publish
Publish the project for deployment using the dotnet publish command. This prepares the project for deployment by creating an output directory with all necessary files:
Example
dotnet publish -c Release
Run
Run the ASP.NET Core application locally using the dotnet run command. This starts the development server and runs the application.
Example
dotnet run
Test
Execute unit tests in the project using the dotnet test command. It runs all test projects in the solution.
Example
dotnet test
VSTest
Run tests using the Visual Studio Test Platform (VSTest) with the dotnet vstest command. This is useful for running tests with advanced configurations.
Example
dotnet vstest MyTestProject.dll
Pack
Create a NuGet package from the project using the dotnet pack command. This is helpful for sharing libraries and packages:
Example
dotnet pack
Migrate
Apply database migrations using the Entity Framework Core tools. For example, to apply for pending migrations, use.
Example
dotnet ef database update
Clean
Clean the project output and intermediate build files using the dotnet clean command:
Example
dotnet clean
Sln
Perform operations on a Visual Studio solution file. To list projects in a solution, use:
Example
dotnet sln list
Help
Get help and information about the .NET CLI and its commands:
Example
dotnet --help
Store
Manage the .NET Core tool store, where global tools are stored:
Example
dotnet store list
Watch
Run the project with automatic file watching and restart on changes. It's useful for development with live updates.
Example
dotnet watch run
Format (Available since .NET 6 SDK)
Automatically format source code using the dotnet format command. This ensures code consistency and readability