Merging multiple Visual Studio Solution (.sln) files into one (Outdated)

By | 2011.01.06

Update: As commented by ‘pifcnt’ this is for VS2010 files.

Today I had the daunting task of combining multiple solution files into one. The reason for this was that the project I’m working on originally started as multiple separate solutions with shared projects. Now we find it more convenient to have it in a single solution both for automated build and, at least for some, as a preferred work method.

There are 88 projects split over 22 solutions. I started the task by manually adding them to an empty solution thinking that this will take some time, but not that much. Unfortunately Visual Studio crashed early in the task. I’ve previously Googled for an application to do this and found one that didn’t work.

So I brushed off my black belt in Perl regex and 3-4 hours later I had a script that solved my problem.

It combines all Project sections, corrects relative path to projects, skips the GlobalSection(TeamFoundationVersionControl) and keeps all other GlobalSections with only unique entries on each.

Syntax: merge.pl Relative\Path\To\Solution1.sln,And\Relative\Path\To\Solution1.sln CombinedOutput.sln

Note that you want to be standing in a common root for all projects and you want to put the output file in this path. This script doesn’t check everything, it was made to solve one task – and so it did.

 

2 thoughts on “Merging multiple Visual Studio Solution (.sln) files into one (Outdated)

  1. pifcnt

    Too bad you forgot to mention that it only works for 2010 solution files. BAD! BAD! BAD!

    Reply
    1. tedd Post author

      Been some time since I wrote this post, but I believe it should work with other versions as well (although I haven’t tested it). There is very little change in the project files between versions. Anyway, then I presume you spent a few minutes testing it so just consider this your contribution to my contribution. :)

      Reply

Leave a Reply