linux系统sln命令,dotnet sln

dotnet slndotnet sln

12/07/2020

本文内容

本文适用于: ✔️ .NET Core 2.x SDK 及更高版本This article applies to: ✔️ .NET Core 2.x SDK and later versions

“属性”Name

dotnet sln - 在 .NET 解决方案文件中列出或修改项目。dotnet sln - Lists or modifies the projects in a .NET solution file.

摘要Synopsis

dotnet sln [] [command]

dotnet sln [command] -h|--help

描述Description

使用 dotnet sln 命令,可以便捷地在解决方案文件中列出和修改项目。The dotnet sln command provides a convenient way to list and modify 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, as in the following example:

dotnet new sln

自变量Arguments

SOLUTION_FILE

要使用的解决方案文件。The solution file to use. 如果省略此参数,此命令会搜索当前目录来获取一个解决方案文件。If this argument is omitted, the command searches the current directory for one. 如果未找到解决方案文件或找到多个解决方案文件,则该命令将失败。If it finds no solution file or multiple solution files, the command fails.

选项Options

-h|--help

打印出有关如何使用命令的说明。Prints out a description of how to use the command.

命令Commands

list

列出解决方案文件中的所有项目。Lists all projects in a solution file.

摘要Synopsis

dotnet sln list [-h|--help]

自变量Arguments

SOLUTION_FILE

要使用的解决方案文件。The solution file to use. 如果省略此参数,此命令会搜索当前目录来获取一个解决方案文件。If this argument is omitted, the command searches the current directory for one. 如果未找到解决方案文件或找到多个解决方案文件,则该命令将失败。If it finds no solution file or multiple solution files, the command fails.

选项Options

-h|--help

打印出有关如何使用命令的说明。Prints out a description of how to use the command.

add

将一个或多个项目添加到解决方案文件。Adds one or more projects to the solution file.

摘要Synopsis

dotnet sln [] add [--in-root] [-s|--solution-folder ] [...]

dotnet sln add [-h|--help]

自变量Arguments

SOLUTION_FILE

要使用的解决方案文件。The solution file to use. 如果未指定,此命令会搜索当前目录以获取一个解决方案文件,如果找到多个解决方案文件,则该命令将失败。If it is unspecified, the command searches the current directory for one and fails if there are multiple solution files.

PROJECT_PATH

要添加到解决方案的一个或多个项目的路径。The path to the project or projects to add to the solution. Unix/Linux shell glob 模式扩展由 dotnet sln 命令正确处理。Unix/Linux shell globbing pattern expansions are processed correctly by the dotnet sln command.

选项Options

-h|--help

打印出有关如何使用命令的说明。Prints out a description of how to use the command.

--in-root

将项目放在解决方案的根目录下,而不是创建解决方案文件夹。Places the projects in the root of the solution, rather than creating a solution folder. 自 .NET Core 3.0 SDK 起可用。Available since .NET Core 3.0 SDK.

-s|--solution-folder

要将项目添加到的目标解决方案文件夹路径。The destination solution folder path to add the projects to. 自 .NET Core 3.0 SDK 起可用。Available since .NET Core 3.0 SDK.

remove

从解决方案文件中删除一个或多个项目。Removes a project or multiple projects from the solution file.

摘要Synopsis

dotnet sln [] remove [...]

dotnet sln [] remove [-h|--help]

自变量Arguments

SOLUTION_FILE

要使用的解决方案文件。The solution file to use. 如果保留未指定,此命令会搜索当前目录以获取一个解决方案文件,如果找到多个解决方案文件,则该命令将失败。If is left unspecified, the command searches the current directory for one and fails if there are multiple solution files.

PROJECT_PATH

要添加到解决方案的一个或多个项目的路径。The path to the project or projects to add to the solution. Unix/Linux shell glob 模式扩展由 dotnet sln 命令正确处理。Unix/Linux shell globbing pattern expansions are processed correctly by the dotnet sln command.

选项Options

-h|--help

打印出有关如何使用命令的说明。Prints out a description of how to use the command.

示例Examples

在解决方案中列出项目:List the projects in a solution:

dotnet sln todo.sln list

将一个 C# 项目添加到解决方案中:Add a C# project to a solution:

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

从解决方案中删除一个 C# 项目:Remove a C# project from a solution:

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

将多个 C# 项目添加到解决方案的根目录中:Add multiple C# projects to the root of a solution:

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

将多个 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 模式(仅限 Unix/Linux)将多个 C# 项目添加到解决方案中:Add multiple C# projects to a solution using a globbing pattern (Unix/Linux only):

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

使用 globbing 模式(仅限 Windows PowerShell)将多个 C# 项目添加到解决方案中:Add multiple C# projects to a solution using a globbing pattern (Windows PowerShell only):

dotnet sln todo.sln add (ls -r **/*.csproj)

使用 glob 模式(仅限 Unix/Linux)将多个 C# 项目从解决方案中删除:Remove multiple C# projects from a solution using a globbing pattern (Unix/Linux only):

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

使用 globbing 模式(仅限 Windows PowerShell)将多个 C# 项目从解决方案中删除:Remove multiple C# projects from a solution using a globbing pattern (Windows PowerShell only):

dotnet sln todo.sln remove (ls -r **/*.csproj)

创建解决方案、控制台应用和两个类库。Create a solution, a console app, and two class libraries. 将项目添加到解决方案,并使用 dotnet sln 的 --solution-folder 选项将类库组织到一个解决方案文件夹中。Add the projects to the solution, and use the --solution-folder option of dotnet sln to organize the class libraries into a solution folder.

dotnet new sln -n mysolution

dotnet new console -o myapp

dotnet new classlib -o mylib1

dotnet new classlib -o mylib2

dotnet sln mysolution.sln add myapp\myapp.csproj

dotnet sln mysolution.sln add mylib1\mylib1.csproj --solution-folder mylibs

dotnet sln mysolution.sln add mylib2\mylib2.csproj --solution-folder mylibs

以下屏幕截图显示了 Visual Studio 2019“解决方案资源管理器”中的结果:The following screenshot shows the result in Visual Studio 2019 Solution Explorer:

78e5a7c70ce11191a1195c70b4806d85.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值