← 返回命令列表

Linux command

dotnet-run 命令

文本

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

常用示例

Run current project

dotnet run

Run with arguments

dotnet run -- [arg1] [arg2]

Run specific project

dotnet run --project [path/to/project.csproj]

Run in Release

dotnet run -c Release

Run without building

dotnet run --no-build

Run specific framework

dotnet run -f [net8.0]

说明

dotnet run builds and executes a .NET project in one step. It's the standard way to run applications during development without creating deployment artifacts. The double-dash separates dotnet options from arguments passed to the application. Launch profiles in launchSettings.json can configure environment variables and arguments for development scenarios. For web applications, dotnet run starts the development server with hot reload support in newer versions.

参数

--project _PATH_
Project to run.
-c, --configuration _CONFIG_
Build configuration.
-f, --framework _FRAMEWORK_
Target framework.
--no-build
Run without building first.
--no-restore
Skip package restore.
--launch-profile _NAME_
Launch profile to use from launchSettings.json.
--no-launch-profile
Do not use any launch profile.
--arch _ARCH_
Target architecture (e.g., x86, x64, arm64).
-- _ARGS_
Arguments to pass to application.
--help
Display help information.

FAQ

What is the dotnet-run command used for?

dotnet run builds and executes a .NET project in one step. It's the standard way to run applications during development without creating deployment artifacts. The double-dash separates dotnet options from arguments passed to the application. Launch profiles in launchSettings.json can configure environment variables and arguments for development scenarios. For web applications, dotnet run starts the development server with hot reload support in newer versions.

How do I run a basic dotnet-run example?

Run `dotnet run` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --project _PATH_ do in dotnet-run?

Project to run.