Solution files (.sln) have been integral to the .NET ecosystem for as long as I can remember, they serve to define a workspace for organizing and managing multiple projects that are part of a larger application. However, in the age of open formats, solutions files are clearly anachronistic and in a practical sense have some clear deficiencies.
Here are just a few issues I have personally experienced: -
- Manual edits are messy
- Merge conflicts are numerous
- Lots of verbose and redundant content
- Poorly documented non-standard format
To overcome these issues, starting with .NET SDK 9.0.200, the dotnet CLI supports building and interacting with a new simpler Solution file format (.slnx). Of course, this new file format is supported by the latest version of Visual Studio (17.13 or later). The new .slnx format is designed for wide adoption, and is also currently supported in MSBuild and C# Dev Kit. Additionally, there is an open source serializer that supports both formats (vs-solutionpersistence).
Here is a quick look at the simpler file format:
<Solution> <Project Path="MyWebApp\MyWebApp.csproj" /> </Solution>
Yep, way better!
To save a solution in the new file format, select the solution node in Visual Studio’s Solution Explorer, then go to File->Save Solution As… and choose the “XML Solution File (*.SLNX)” format. The solution will then be saved as a .slnx file.
To open a .slnx file, use the File->Open command and select the .slnx file. Note that Visual Studio is not registered as the default handler for .slnx files, so they won’t open in Visual Studio by default for now.
Couple of things to consider before about before upgrading:
- If you are forced to use an older versions of Visual Studio (prior to 17.14) this is not for you.
- It is strongly recommend not having both .sln and .slnx files in the same repository. Commands like dotnet sln will not automatically detect the correct solution file.
For my open-source projects, I intend to hold off on upgrading for now. Personally, I’d like to see broader adoption of Visual Studio 17.14 first, and I also need it to be set as the default handler for .slnx files. My recommendation is to check the FAQ section, as it likely addresses most of your key considerations, before making the switch.