Introduction
A .sln file is a solution for Microsoft’s
Visual Studio: the list of projects
that make up a piece of software, such as a C# or C++
project, with the build configurations they share,
like Debug and Release for each platform. Opening the solution opens all its projects
together, and building it builds them in the right order. The projects keep their own
settings in their own files.
Structure
A solution is a text file, usually saved as UTF-8 with a byte order mark. It opens with
a line naming the format version, then comments and settings recording which Visual
Studio wrote it. Each project has a Project block giving a GUID for the kind
of project, its name, its path and its own GUID. A Global block follows,
made of GlobalSection blocks: the solution’s configurations, how each one
maps to each project’s configurations, and other settings. Every line, the project
type GUIDs and each section are on the lines and
sections page.
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App", "App\App.csproj", "{6F1D3C42-...}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
EndGlobal
Not described
Known, not yet covered
- Reference: the line form of
SolutionItemsand where recent Visual Studio versions place sections; see layout. The XML solution format is on its own page. - Viewer: the explorer shows the lines, project blocks and sections of a
.slnand reports what MSBuild anddotnet slnrefuse; the sections Visual Studio extensions keep (ExtensibilityGlobalsand similar) are listed but their entries are not interpreted, and a solution filter (.slnf, JSON) and the user options file (.suo, binary) are not read.
Also used for
- Visual Studio XML solution – The projects and build configurations of a Visual Studio solution, as XML.
Links
Software
- Visual Studio – Microsoft’s IDE, which makes and opens solutions (Windows)
- JetBrains Rider – JetBrains’ .NET IDE, which opens solutions (Windows, macOS, Linux)
- .NET SDK – its
dotnet buildanddotnet slnread and change solutions (Windows, macOS, Linux) - MSBuild – Microsoft’s build engine, which builds a whole solution (Windows, macOS, Linux)
- Visual Studio Code – code editor that opens solutions with the C# Dev Kit extension (Windows, macOS, Linux)