12

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,989
  • 8
  • 30
  • 52
  • 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

12

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
  • 8,575
  • 4
  • 56
  • 95
2

Add Microsoft.Build nuget and then:

using Microsoft.Build.Construction;
var sln = SolutionFile.Parse(filename);
Yola
  • 18,496
  • 11
  • 65
  • 106
1

Take a look at:

https://github.com/tapika/syncProj

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

TarmoPikaro
  • 4,723
  • 2
  • 50
  • 62