A .slnx file does what a .sln file does
(it lists the projects of a solution and how each builds in each configuration) in XML
that people can read and merge. Visual Studio and dotnet sln read and write it,
through Microsoft’s open-source
vs-solutionpersistence
library. The root is Solution, with no namespace, and the file is UTF-8.
<Solution>
<Configurations>
<Platform Name="Any CPU" />
<Platform Name="x64" />
</Configurations>
<Folder Name="/src/">
<Project Path="src/App/App.csproj" />
<Project Path="src/Lib/Lib.fsproj" />
</Folder>
<Folder Name="/Solution Items/">
<File Path=".editorconfig" />
</Folder>
<Project Path="tests/Tests.csproj">
<Build Solution="Debug|*" Project="false" />
</Project>
</Solution>
Elements and attributes
| Element | Inside | Attributes | Meaning |
|---|---|---|---|
Solution | root | Description, Version | The solution. Version is a number such as 1.0; a version above 1 is refused as newer than the format. |
Configurations | Solution | The build types and platforms of the solution. When it is missing the solution has Debug and Release and Any CPU. | |
BuildType | Configurations | Name (required) | A build type of the solution (Debug, Release). |
Platform | Configurations | Name (required) | A platform (Any CPU, x64). |
ProjectType | Configurations | Name, TypeId, Extension, BasedOn, IsBuildable, SupportsPlatform | Defines a project type: a type id (a GUID) or extension, what it is based on (a loop of BasedOn is refused), whether it builds and whether it has platforms. It may hold the rules below. |
Folder | Solution | Name (required), Id | A solution folder. The name starts and ends with / and nests by its path: /src/Libs/ is inside /src/. Names are unique. |
File | Folder | Path (required) | A file shown in the folder (not built). |
Project | Solution, Folder | Path (required), Type, DisplayName, Id, DefaultStartup | A project: its file (relative, or a file: or https: address). Type names a project type; without it the extension decides. Paths are unique. Id is a GUID, unique. |
BuildType, Platform, Build, Deploy | Project, ProjectType | Solution, Project (Platform requires Project) | Configuration rules: which project configuration a solution configuration (Debug|Any CPU, with * for any) maps to; Build with Project="false" leaves the project out of that configuration, Deploy turns deployment on. |
BuildDependency | Project | Project (required) | A project this one must be built after. |
Properties | Solution, Folder, Project | Name (required), Scope | A named set of properties a tool keeps: a debugger’s settings, extensibility globals. Scope is PostLoad. |
Property | Properties | Name (required), Value | One property; no value means an empty one. |
Elements and attributes outside this table are kept by the tools when they save, so the explorer notes them instead of calling them errors.
What makes a .slnx invalid
Each of these was checked with dotnet sln … list, which refuses the file.
- The root is not
Solution. Versionis not a number (v1.0) or is above 1 (2.0).- A solution folder name does not start and end with
/, or two folders have one name. - Two projects have one path, or two projects or two folders have one
Id. - Project types are based on each other in a loop.
Backslashes in paths and some older values are tolerated.
In the explorer
The file opens as XML with the elements above explained, and tabs for the projects (with their solution folder, type and rules), the folders, the files in folders, the configurations, the project types and the property sets, with every problem listed.
Not described
Known, not yet covered
- Reference: how Visual Studio maps built-in project types and legacy project type ids to
Typenames (a table in the library’s source); the rules for choosing configurations when none are written.
Sources
The vs-solutionpersistence
repository: Slnx.xsd (elements, attributes, required attributes), its test
solutions (valid and invalid files, including Everything.slnx), and the
behaviour of dotnet sln on each of them, which reads the format with this
library. The Id and DefaultStartup attributes are in the library’s
test files and not in the schema.
Links
Reference
- vs-solutionpersistence – Microsoft’s open-source library that reads and writes solution files
- New, simpler solution file format – the Visual Studio team’s introduction to .slnx