11

I used text editor to open an .sln file, it looks like a tree structure, but it's not xml format.

Do you know what format it is, and can we process it using C#, like processing xml conveniently?

vik santata
  • 2,795
  • 7
  • 26
  • 49
  • 3
    I've never understood why MS decided to not use XML format for .sln files. They did use XML for proj files! :p – bytedev Jul 24 '18 at 15:02

3 Answers3

10

Here is the description of the format: https://msdn.microsoft.com/en-us/library/bb165951(v=vs.140).aspx

You're right, it is not XML, but another text-based format:

The .sln file contains text-based information the environment uses to find and load the name-value parameters for the persisted data and the project VSPackages it references.

And for parsing the file you can look at this question: Parsing Visual Studio Solution files

Community
  • 1
  • 1
astef
  • 7,272
  • 3
  • 46
  • 87
1

Take a look at:

https://github.com/tapika/syncProj

Solution.LoadSolution will decrypt solution information for you in code.

TarmoPikaro
  • 3,886
  • 1
  • 38
  • 52
0

Add Microsoft.Build nuget and then:

using Microsoft.Build.Construction;
var sln = SolutionFile.Parse(filename);
Yola
  • 17,545
  • 11
  • 60
  • 100