Click here to Skip to main content
15,919,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to read solution file for my project, let me know the mechanism other than solution parser.
Posted
Updated 17-Nov-22 0:38am
Comments
n.podbielski 6-Nov-12 5:22am    
And for what you need that?
manoj629 6-Nov-12 5:30am    
I need to get project name and version fron solution file
Ankur\m/ 6-Nov-12 5:23am    
I Googled for 'Solution Parser' and this was the first result - http://stackoverflow.com/questions/2192545/visual-studio-solution-parser.
Might help!

SLN files are text files, you can get the version of the solution file by reading the first line :
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "consoletest", "consoletest\consoletest.csproj", "{6BADD8B3-618E-412A-BBCA-8420EFD5B62E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fastJSON", "fastJSON\fastJSON.csproj", "{207E91B1-C9F8-4913-88E1-3549EF5F3273}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{F4BFF0D2-45F6-413B-B1E7-BC4A0D6596FC}"
EndProject
...

The project names are there also as you can see from the above.
 
Share this answer
 
Add NuGet package Microsoft.Build to the project.

// Add the using on top of the cs-file.
using Microsoft.Build.Construction;

// In your method:
string filename = @"C:\src\sln-folder\theSlnFile.sln";
var sln = SolutionFile.Parse(filename);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900