dotnet-sln(1)

πŸ“¦
version 11.0.0~rc3 Β· 6 versions
, in alpine 3.24, centos-stream 10, centos-stream 9, fedora 43, fedora 44, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– dotnet-sln β€” the manual page, but make it cute πŸ’–

okay so bestie, this is the page for dotnet-sln(1) from the .NET Documentation, and it's genuinely one of the most useful little commands in the whole SDK, no cap. Let's get into it. πŸ¦‹

This article applies to: βœ”οΈ .NET 6 SDK and later versions

✨ NAME ✨

dotnet-sln β€” Lists or modifies the projects in a .NET solution file, or migrates the file to an .slnx file. πŸ’…


🌸 SYNOPSIS 🌸

dotnet sln [<SOLUTION_FILE>] [command]

dotnet sln [command] -h|--help

πŸ’œ DESCRIPTION πŸ’œ

The dotnet sln command is your lowkey-bestie way to list and modify projects in a solution file. That's the whole vibe. 🫢

πŸŽ€ Create a solution file πŸŽ€

Real talk: to even use dotnet sln, the solution file has to already exist. It will not manifest one out of thin air for you. If you need to make one, use the dotnet new command with the sln template name. ✨

The following example creates an .slnx file in the current folder, with the same name as the folder:

dotnet new sln

The following example creates an .slnx file in the current folder, with the specified file name:

dotnet new sln --name MySolution

The following example creates an .slnx file in the specified folder, with the same name as the folder:

dotnet new sln --output MySolution
⚠️ In .NET 9 and earlier versions, dotnet new sln creates an .sln file instead of an .slnx file. Do not be surprised by this. It's giving legacy behavior. πŸ’€

🌈 ARGUMENTS 🌈

  • SOLUTION_FILE β€” The solution file to use (either an .sln or .slnx file).

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. 😭


πŸ’… OPTIONS πŸ’…

  • -?, -h, --help β€” Prints out a description of how to use the command. Your little helper bestie fr fr. 🫢

πŸ‘‘ Commands πŸ‘‘

The following commands are available:

  • list
  • add
  • remove
  • migrate

🌸 list 🌸

Lists all projects in a solution file. That's it, that's the whole job, and it ate. πŸ‘‘

SYNOPSIS

dotnet sln list [-h|--help]

ARGUMENTS

  • SOLUTION_FILE β€” The solution file (.sln or .slnx file) or solution filter (.slnf file) to use.

If unspecified, the command searches the current directory for an .sln, .slnx, or .slnf file and, if it finds exactly one, uses that file. If multiple solution files or filters are found, the user is prompted to specify a file explicitly. If none are found, the command fails. 😭

(Support for .slnf files was added in .NET SDK 9.0.3xx.) iykyk πŸ’«

OPTIONS

  • -?, -h, --help β€” Prints out a description of how to use the command. πŸŽ€

πŸ¦‹ add πŸ¦‹

Adds one or more projects to the solution file. Plural. Multiple. Go off. ✨

SYNOPSIS

dotnet sln [<SOLUTION_FILE>] add [--in-root] [-s|--solution-folder <PATH>] <PROJECT_PATH> [<PROJECT_PATH>...]
dotnet sln add [-h|--help]

ARGUMENTS

  • SOLUTION_FILE β€” The solution file to use (either an .sln or .slnx file).

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. 😭

  • PROJECT_PATH β€” The path to the project or projects to add to the solution. Unix/Linux shell globbing pattern (https://en.wikipedia.org/wiki/Glob_(programming)) expansions are processed correctly by the dotnet sln command. 🌟

If PROJECT_PATH includes folders that contain the project folder, that portion of the path is used to create solution folders. For example, the following commands create a solution with myapp in solution folder folder1/folder2:

dotnet new sln
dotnet new console --output folder1/folder2/myapp
dotnet sln add folder1/folder2/myapp

You can override this default behavior by using the --in-root or the -s|--solution-folder <PATH> option. πŸŽ€

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. Can't be used with -s|--solution-folder. Pick a lane bestie, you can't have both. πŸ’€
  • -s, --solution-folder <PATH> β€” The destination solution folder path to add the projects to. Can't be used with --in-root. Same energy. 🚫

πŸ’œ remove πŸ’œ

Removes a project or multiple projects from the solution file. Bye bye bestie, we love a clean solution. πŸ‘‹

SYNOPSIS

dotnet sln [<SOLUTION_FILE>] remove <PROJECT_PATH|PROJECT_NAME> [<PROJECT_PATH|PROJECT_NAME>...]
dotnet sln [<SOLUTION_FILE>] remove [-h|--help]

ARGUMENTS

  • SOLUTION_FILE β€” The solution file to use (either an .sln or .slnx file).

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. 😭

  • PROJECT_PATH or PROJECT_NAME β€” The path to, or name of, the project or projects to remove from the solution. Unix/Linux shell globbing pattern (https://en.wikipedia.org/wiki/Glob_(programming)) expansions are processed correctly by the dotnet sln command. 🌈

If a project name is provided instead of a path, the project in the solution that matches the name, regardless of its path, is removed. If more than one matching project is found in the solution, the command errors out. Omit the project file extension in the name. (Support for removing projects by name was added in .NET 10.) πŸ“

OPTIONS

  • -?, -h, --help β€” Prints out a description of how to use the command. πŸ’…

🧚 migrate 🧚

Generates an .slnx solution file from an .sln file. A glow-up, but for your solution file. ✨

SYNOPSIS

dotnet sln [<SOLUTION_FILE>] migrate
dotnet sln [<SOLUTION_FILE>] migrate [-h|--help]

ARGUMENTS

  • SOLUTION_FILE β€” The .sln solution file to migrate.

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. 😭

🚨 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. Not me getting blocked by my own migration. πŸ’€

OPTIONS

  • -?, -h, --help β€” Prints out a description of how to use the command. πŸŽ€

⭐ EXAMPLES ⭐

  • List the projects in a solution:
dotnet sln todo.slnx list
  • Add a C# project to a solution:
dotnet sln add todo-app/todo-app.csproj
  • Remove a C# project from a solution:
dotnet sln remove todo-app/todo-app.csproj
  • Add multiple C# projects to the root of a solution:
dotnet sln todo.slnx add todo-app/todo-app.csproj back-end/back-end.csproj --in-root
  • Add multiple C# projects to a solution:
dotnet sln todo.slnx add todo-app/todo-app.csproj back-end/back-end.csproj
  • Remove multiple C# projects from a solution:
dotnet sln todo.slnx remove todo-app/todo-app.csproj back-end/back-end.csproj
  • Add multiple C# projects to a solution using a globbing pattern (Unix/Linux only):
dotnet sln todo.slnx add **/*.csproj
  • Add multiple C# projects to a solution using a globbing pattern (Windows PowerShell only):
dotnet sln todo.slnx add (ls -r **/*.csproj)
  • Remove multiple C# projects from a solution using a globbing pattern (Unix/Linux only):
dotnet sln todo.slnx remove **/*.csproj
  • Remove multiple C# projects from a solution using a globbing pattern (Windows PowerShell only):
dotnet sln todo.slnx remove (ls -r **/*.csproj)
  • Generate an .slnx file from a .sln file:
dotnet sln todo.sln migrate
  • 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:
dotnet new sln -n mysolution
dotnet new console -o myapp
dotnet new classlib -o mylib1
dotnet new classlib -o mylib2
dotnet sln mysolution.slnx add myapp\myapp.csproj
dotnet sln mysolution.slnx add mylib1\mylib1.csproj --solution-folder mylibs
dotnet sln mysolution.slnx add mylib2\mylib2.csproj --solution-folder mylibs

The following screenshot shows the result in Visual Studio 2019 Solution Explorer:

:::image type="content" source="media/dotnet-sln/dotnet-sln-solution-folder.png" alt-text="Solution Explorer showing class library projects grouped into a solution folder.":::

That's the visual, bestie β€” the projects all nestled in a solution folder like they belong together. 🌸


πŸ’« SEE ALSO πŸ’«


okay and that's the whole page, you're literally a dotnet sln expert now, main character energy fr fr πŸ’…βœ¨

This page is from the .NET docs, dated 2025-10-30, and it's dotnet-sln(1) β€” go forth and organize your projects, bestie. πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from