views:

977

answers:

2

Does anyone know of a .NET library/script for parsing Visual Studio solution (SLN) files? I would like to write an app that merges multiple solutions into one while saving the relative build order.

A: 

This web site provides source code for converting VS2008/2005 solution files. It may provide insights for creating your Solution merge utility.

http://www.emmet-gray.com/Articles/ProjectConverter.htm

Mark Maslar
+1  A: 

I can't really offer you a library and my guess is there isn't one that exists out there. But I've spent a deal of time messing around with .sln files in batch editting scenarios and I've found Powershell to be a very useful tool for this task. The .SLN format is pretty simple and can be almost completely parsed with a few quick and dirty expressions. For Example

Included Project files.

gc ConsoleApplication30.sln | 
  ? { $_ -match "^Project" } | 
  %{ $_ -match ".*=(.*)$" | out-null ; $matches[1] } | 
  %{ $_.Split(",")[1].Trim().Trim('"') }

It's not always pretty, but it is an effective way to do batch processing.

JaredPar
Yeah, that's what I've been doing so far
Filip