Welcome to the new Visual Studio SLNX Solution File

Welcome to the new Visual Studio SLNX Solution File

Welcome to the new Visual Studio SLNX Solution File

For many years, there has been a lot of criticism of Visual Studio’s current solution format. It is very difficult to read, it does not follow any standard and you need your own parser. Changes are virtually only possible with Visual Studio — and there are constant merge problems.

Microsoft has now tackled the problem and developed a new format based on XML. It is easier to read, follows this XML standard and can also be edited without Visual Studio. The new format is currently being introduced as a preview in Visual Studio 2022 v17.10 and must be activated manually in the options.

After activating the preview feature “use solution file persistence model”, the file can be created by clicking “Save as…”.

As an example, here is a current solution file that contains two projects:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34407.89
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{D5991777-2F40-49C9-BB75-78228CB25021}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2BDE57F7-2328-4C85-998C-DE491FB76CFE}"
 ProjectSection(SolutionItems) = preProject
  Directory.Build.props = Directory.Build.props
 EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{F1E36EA1-B227-4311-BA97-DFFFD7B3D777}"
EndProject
Global
 GlobalSection(SolutionConfigurationPlatforms) = preSolution
  Debug|Any CPU = Debug|Any CPU
  Release|Any CPU = Release|Any CPU
 EndGlobalSection
 GlobalSection(ProjectConfigurationPlatforms) = postSolution
  {D5991777-2F40-49C9-BB75-78228CB25021}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {D5991777-2F40-49C9-BB75-78228CB25021}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {D5991777-2F40-49C9-BB75-78228CB25021}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {D5991777-2F40-49C9-BB75-78228CB25021}.Release|Any CPU.Build.0 = Release|Any CPU
  {F1E36EA1-B227-4311-BA97-DFFFD7B3D777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  {F1E36EA1-B227-4311-BA97-DFFFD7B3D777}.Debug|Any CPU.Build.0 = Debug|Any CPU
  {F1E36EA1-B227-4311-BA97-DFFFD7B3D777}.Release|Any CPU.ActiveCfg = Release|Any CPU
  {F1E36EA1-B227-4311-BA97-DFFFD7B3D777}.Release|Any CPU.Build.0 = Release|Any CPU
 EndGlobalSection
 GlobalSection(SolutionProperties) = preSolution
  HideSolutionNode = FALSE
 EndGlobalSection
 GlobalSection(ExtensibilityGlobals) = postSolution
  SolutionGuid = {CB456CB7-F491-48D5-B012-38A64C9AF96E}
 EndGlobalSection
EndGlobal        

As you can see, the file is very large, very bloated with unnecessarily duplicated information — and, at first glance, lacks structure.

Here is exactly the same solution with the new solution file.

<Solution>
  <Folder Name="/Solution Items/">
    <File Path="Directory.Build.props" />
  </Folder>
  <Project Path="ClassLibrary1\ClassLibrary1.csproj" />
  <Project Path="ConsoleApp1\ConsoleApp1.csproj" />
</Solution>        

The 35 lines have been reduced to just 7 lines. The file is much easier to read and understand as it follows the XML standard.

Huge improvement!

Please note

There is currently no option in the .NET CLI. However, it is planned that the new format will also be supported in the .NET CLI in the future — currently it is a pure preview and should not be used in productive environments.

Nevertheless, please try out the new file and give Microsoft feedback!

Author

Benjamin Abt

Ben is a passionate developer and software architect and especially focused on .NET, cloud and IoT. In his professional he works on high-scalable platforms for IoT and Industry 4.0 focused on the next generation of connected industry based on Azure and .NET. He runs the largest german-speaking C# forum myCSharp.de, is the founder of the Azure UserGroup Stuttgart, a co-organizer of the AzureSaturday, runs his blog, participates in open source projects, speaks at various conferences and user groups and also has a bit free time. He is a Microsoft MVP since 2015 for .NET and Azure.

Originally published at https://schwabencode.com on April 10, 2024.

要查看或添加评论,请登录

BEN ABT的更多文章

社区洞察

其他会员也浏览了