← 返回命令列表

Linux command

dotnet 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create new project

dotnet new [console] -n [MyApp]

Build project

dotnet build

Run project

dotnet run

Run tests

dotnet test

Add NuGet package

dotnet add package [PackageName]

Restore dependencies

dotnet restore

Publish for deployment

dotnet publish -c Release

List installed SDKs

dotnet --list-sdks

说明

dotnet is the .NET CLI for creating, building, running, and publishing .NET applications. It supports C#, F#, and Visual Basic across console apps, web APIs, libraries, and more. The CLI handles the full development workflow from project creation through deployment. It manages NuGet packages, runs tests, and produces deployment artifacts. Templates provide starting points for various application types. dotnet works cross-platform on Windows, macOS, and Linux, enabling .NET development everywhere.

参数

new _TEMPLATE_
Create project from template.
build
Build the project.
run
Build and run the project.
test
Run unit tests.
publish
Publish for deployment.
add package _NAME_
Add NuGet package reference.
restore
Restore NuGet packages.
-c _CONFIG_
Build configuration (Debug, Release).
--help
Display help information.

FAQ

What is the dotnet command used for?

dotnet is the .NET CLI for creating, building, running, and publishing .NET applications. It supports C#, F#, and Visual Basic across console apps, web APIs, libraries, and more. The CLI handles the full development workflow from project creation through deployment. It manages NuGet packages, runs tests, and produces deployment artifacts. Templates provide starting points for various application types. dotnet works cross-platform on Windows, macOS, and Linux, enabling .NET development everywhere.

How do I run a basic dotnet example?

Run `dotnet new [console] -n [MyApp]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does new _TEMPLATE_ do in dotnet?

Create project from template.