You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/tools/dotnet-sln.md
+63-17Lines changed: 63 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
---
2
2
title: dotnet sln command
3
3
description: The dotnet-sln command provides a convenient option to add, remove, and list projects in a solution file.
4
-
ms.date: 05/18/2022
4
+
ms.date: 02/24/2025
5
5
---
6
6
# dotnet sln
7
7
8
8
**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions
9
9
10
10
## Name
11
11
12
-
`dotnet sln` - Lists or modifies the projects in a .NET solution file.
12
+
`dotnet sln` - Lists or modifies the projects in a .NET solution file, or migrates the file to an *.slnx* file.
13
13
14
14
## Synopsis
15
15
@@ -49,14 +49,23 @@ dotnet new sln --output MySolution
49
49
50
50
-**`SOLUTION_FILE`**
51
51
52
-
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.
52
+
The solution file to use (either an *.sln* or *.slnx* file).
53
+
54
+
If unspecified, the command searches the current directory for an *.sln* or *.slnx* file and, if it finds exactly one, uses that file. If multiple solution files are found, the user is prompted to specify a file explicitly. If none are found, the command fails.
53
55
54
56
## Options
55
57
56
58
[!INCLUDE [help](../../../includes/cli-help.md)]
57
59
58
60
## Commands
59
61
62
+
The following commands are available:
63
+
64
+
-[`list`](#list)
65
+
-[`add`](#add)
66
+
-[`remove`](#remove)
67
+
-[`migrate`](#migrate)
68
+
60
69
### `list`
61
70
62
71
Lists all projects in a solution file.
@@ -71,7 +80,9 @@ dotnet sln list [-h|--help]
71
80
72
81
-**`SOLUTION_FILE`**
73
82
74
-
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.
83
+
The solution file to use (either an *.sln* or *.slnx* file).
84
+
85
+
If unspecified, the command searches the current directory for an *.sln* or *.slnx* file and, if it finds exactly one, uses that file. If multiple solution files are found, the user is prompted to specify a file explicitly. If none are found, the command fails.
75
86
76
87
#### Options
77
88
@@ -92,7 +103,9 @@ dotnet sln add [-h|--help]
92
103
93
104
-**`SOLUTION_FILE`**
94
105
95
-
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.
106
+
The solution file to use (either an *.sln* or *.slnx* file).
107
+
108
+
If unspecified, the command searches the current directory for an *.sln* or *.slnx* file and, if it finds exactly one, uses that file. If multiple solution files are found, the user is prompted to specify a file explicitly. If none are found, the command fails.
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.
151
+
The solution file to use (either an *.sln* or *.slnx* file).
152
+
153
+
If unspecified, the command searches the current directory for an *.sln* or *.slnx* file and, if it finds exactly one, uses that file. If multiple solution files are found, the user is prompted to specify a file explicitly. If none are found, the command fails.
Generates an *.slnx* solution file from an *.sln* file.
166
+
167
+
#### Synopsis
168
+
169
+
```dotnetcli
170
+
dotnet sln [<SOLUTION_FILE>] migrate
171
+
dotnet sln [<SOLUTION_FILE>] migrate [-h|--help]
172
+
```
173
+
174
+
#### Arguments
175
+
176
+
-**`SOLUTION_FILE`**
177
+
178
+
The *.sln* solution file to migrate.
179
+
180
+
If unspecified, the command searches the current directory for an *.sln* file and, if it finds exactly one, uses that file. If multiple *.sln* files are found, the user is prompted to specify a file explicitly. If none are found, the command fails.
181
+
182
+
If you specify an *.slnx* file instead of an *.sln* file, or if an *.slnx* file with the same file name (minus the *.sln* extension) already exists in the directory, the command fails.
- Add multiple C# projects to a solution using a globbing pattern (Unix/Linux only):
187
227
188
228
```dotnetcli
189
-
dotnet sln todo.sln add **/*.csproj
229
+
dotnet sln todo.slnx add **/*.csproj
190
230
```
191
231
192
232
- Add multiple C# projects to a solution using a globbing pattern (Windows PowerShell only):
193
233
194
234
```dotnetcli
195
-
dotnet sln todo.sln add (ls -r **/*.csproj)
235
+
dotnet sln todo.slnx add (ls -r **/*.csproj)
196
236
```
197
237
198
238
- Remove multiple C# projects from a solution using a globbing pattern (Unix/Linux only):
199
239
200
240
```dotnetcli
201
-
dotnet sln todo.sln remove **/*.csproj
241
+
dotnet sln todo.slnx remove **/*.csproj
202
242
```
203
243
204
244
- Remove multiple C# projects from a solution using a globbing pattern (Windows PowerShell only):
205
245
206
246
```dotnetcli
207
-
dotnet sln todo.sln remove (ls -r **/*.csproj)
247
+
dotnet sln todo.slnx remove (ls -r **/*.csproj)
248
+
```
249
+
250
+
- Generate an *.slnx* file from a *.sln* file:
251
+
252
+
```dotnetcli
253
+
dotnet sln todo.sln migrate
208
254
```
209
255
210
256
- Create a solution, a console app, and two class libraries. Add the projects to the solution, and use the `--solution-folder` option of `dotnet sln` to organize the class libraries into a solution folder.
0 commit comments