dotnet slndotnet sln

本主題適用於:✓ .NET Core 1.x SDK .NET Core 2.x SDKThis topic applies to: ✓ .NET Core 1.x SDK .NET Core 2.x SDK

名稱Name

dotnet sln - 修改.NET Core 方案檔。dotnet sln - Modifies a .NET Core solution file.

概要Synopsis

dotnet sln [<SOLUTION_NAME>] add <PROJECT> <PROJECT> ...
dotnet sln [<SOLUTION_NAME>] add <GLOBBING_PATTERN>
dotnet sln [<SOLUTION_NAME>] remove <PROJECT> <PROJECT> ...
dotnet sln [<SOLUTION_NAME>] remove <GLOBBING_PATTERN>
dotnet sln [<SOLUTION_NAME>] list
dotnet sln [-h|--help]

說明Description

dotnet sln 命令提供方便在方案檔中新增、移除及列出專案的方式。The dotnet sln command provides a convenient way to add, remove, and list projects in a solution file.

若要使用 dotnet sln 命令,方案檔必須已經存在。To use the dotnet sln command, the solution file must already exist. 如果您需要建立一個,請使用 dotnet new 命令,如下列範例:If you need to create one, use the dotnet new command, like in the following example:

dotnet new sln

命令Commands

add <PROJECT> ...

add <GLOBBING_PATTERN>

將一個專案或多個專案加入至方案檔。Adds a project or multiple projects to the solution file. 以 Unix/Linux 為基礎的終端機上支援 Globbing 模式 (英文)Globbing patterns are supported on Unix/Linux based terminals.

remove <PROJECT> ...

remove <GLOBBING_PATTERN>

從方案檔中移除一個專案或多個專案。Removes a project or multiple projects from the solution file. 以 Unix/Linux 為基礎的終端機上支援 Globbing 模式 (英文)Globbing patterns are supported on Unix/Linux based terminals.

list

列出方案檔中的所有專案。Lists all projects in a solution file.

引數Arguments

SOLUTION_NAME

要使用的方案檔。Solution file to use. 如果未指定,命令會在目前的目錄中搜尋一個專案檔。If not specified, the command searches the current directory for one. 如果目錄中有多個方案檔,請務必指定一個方案檔。If there are multiple solution files in the directory, one must be specified.

選項Options

-h|--help

印出命令的簡短說明。Prints out a short help for the command.

範例Examples

將 C# 專案新增至方案:Add a C# project to a solution:

dotnet sln todo.sln add todo-app/todo-app.csproj

移除方案中的 C# 專案:Remove a C# project from a solution:

dotnet sln todo.sln remove todo-app/todo-app.csproj

將多個 C# 專案新增至方案:Add multiple C# projects to a solution:

dotnet sln todo.sln add todo-app/todo-app.csproj back-end/back-end.csproj

從方案中移除多個 C# 專案:Remove multiple C# projects from a solution:

dotnet sln todo.sln remove todo-app/todo-app.csproj back-end/back-end.csproj

使用 Glob 模式將多個 C# 專案新增至方案:Add multiple C# projects to a solution using a globbing pattern:

dotnet sln todo.sln add **/*.csproj

使用 Glob 模式從方案中移除多個 C# 專案:Remove multiple C# projects from a solution using a globbing pattern:

dotnet sln todo.sln remove **/*.csproj

注意

萬用字元不是 CLI 功能,而是命令殼層的功能。Globbing is not a CLI feature but rather a feature of the command shell. 若要成功擴充檔案,您必須使用支援萬用字元的殼層。To successfully expand the files, you must use a shell that supports globbing. 如需萬用字元的詳細資訊,請參閱維基百科 (英文)。For more information about globbing, see Wikipedia.