Dotnet logo

.NET Tools

Essential productivity kit for .NET and game developers

.NET Tools How-To's

Support for SLNX Solution Files

For nearly twenty years, the .NET community has enjoyed working with solution files (*.sln). Due to their tooling-centered format, manually changing these files has always been challenging. Merge conflicts in solution files—much like merging CSPROJ files—were commonplace and often resulted in corrupted files or lost changes.

The structure of SLN files is overly verbose—an empty solution file starts at nine lines of code with 225 characters! Every added project contributes six lines and duplicated GUID references throughout the file. On top of that, it often seems impossible to remember which of the two GUIDs represents the project ID. Also, the duplication of project names and solution items offers no real benefit despite expectations:

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpConsoleApp", "CSharpConsoleApp\CSharpConsoleApp.csproj", "{56AC6E9D-28FA-60C6-322C-7A6C3A2CF147}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionFolder1", "SolutionFolder1", "{C6BC3CF2-0D31-8D54-D372-94C86BEC98BA}"
    ProjectSection(SolutionItems) = preProject
        global.json = global.json
    EndProjectSection
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {56AC6E9D-28FA-60C6-322C-7A6C3A2CF147}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {56AC6E9D-28FA-60C6-322C-7A6C3A2CF147}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {56AC6E9D-28FA-60C6-322C-7A6C3A2CF147}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {56AC6E9D-28FA-60C6-322C-7A6C3A2CF147}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
EndGlobal

But enough ranting. Microsoft introduced a new SLNX format based on XML as a solution (pun intended!) to fix these issues. We at JetBrains are excited to announce that Rider provides beta support already!

Getting Started

You can translate your existing solution to an SLNX file by right-clicking on its node in the Explorer window. From there, you can choose Save as… | Save as XML Solution (.slnx):

Saving a Solution in SLNX Format
Saving a Solution in SLNX Format

Next to your original SLN file, you will now see a clean and minimal SLNX file that everyone should feel confident to edit manually. Our example from the introduction looks as follows:

<Solution>
    <Folder Name="/SolutionFolder/">
        <File Path="global.json" />
    </Folder>
    <Project Path="ConsoleApp1\ConsoleApp1.csproj" Type="Classic C#" />
</Solution>

After you confirm the saving dialog, Rider will also offer you to open the freshly created SLNX file:

Prompt to open a newly created XML Solution
Prompt to open a newly created XML Solution

You can also translate SLNX files back to the SLN format, which is particularly important if your development environment or team requires both files (more details below). Open an SLNX file, and find the Save as Solution (.sln) action in the very same context menu location:

Saving an XML Solution in SLN Format
Saving an XML Solution in SLN Format

Limitations

Microsoft is still developing the SLNX format as a preview feature, and it has yet to be officially announced. Despite this, the community is excited and eager to migrate, as the format shows immense promise. As a result, there are a few limitations within the broader ecosystem that users should be aware of.

Since there is no official dotnet new template, Rider also currently doesn’t offer one from the New Project dialog.

The .NET CLI and MSBuild don’t yet support SLNX files. Therefore, it’s most certainly necessary to keep both files in your repository so that your CI/CD infrastructure can do its work. Regarding that, please note that Rider does not automatically synchronize the two files.

Conclusion

Although the SLNX format is still in preview, it already looks like a promising answer to the challenges .NET developers have faced for years with the old proprietary SLN format. Rider 2024.3 EAP introduces initial support for reading and writing the new SLNX format based on our research. We look forward to Microsoft publishing the details of the new SLNX schema and making it generally available to the community!

image description