views:

671

answers:

6

I've got alot of projects and I don't have a master solution with everything in it. The reason I want one is for refactoring.

So I was wondering if anybody knew an automatic way to build a solution file. Manually adding all the projects just isn't feasible.

A: 

Create an empty solution, then drag & drop all your projects into it at once?

oefe
The original question stated that manually adding them wasn't feasible.
Pedro
A: 

You can try this (the code below comes from this site, of all sites..)

But if it doesn't work and it would take too much time to debug, I would suggest going for the pain of adding them manually once. Just put some good music and go for it... :)

@oefe I don't think VS.NET allows you to D&D projects into solutions, I've tried that once.

Imports EnvDTE
Imports EnvDTE80
-----------------------------------------------------------------------------------
    Private Shared Sub DoStuff()

        Dim filePath As String = "c:\temp"

        Dim fileName As String = "bld_TestApp.sln"

        Dim fullName As String = Path.Combine(filePath, fileName)

        Dim objType As Type

        Dim objDTE As EnvDTE.DTE

        objType = Type.GetTypeFromProgID("VisualStudio.DTE.8.0")

        objDTE = DirectCast(System.Activator.CreateInstance(objType), EnvDTE.DTE)

        Console.WriteLine(objDTE.Name + ":" + objDTE.Version)


        objDTE.Solution.Create(filePath, fileName)

        objDTE.Solution.AddFromFile("C:\Common.vbproj")

        objDTE.Solution.SaveAs(fullName)


    End Sub
rodbv
A: 

Check out nAnt, the .NET port of Ant. It has the ability to do stuff like this, or to build without it.

Rob Williams
This is quite interesting: I have given the best solution, yet I have been downvoted the most, and not a single comment to explain what the #$%## anyone is thinking. Meanwhile, the worst solution (involving some funky custom code) gets upvoted.
Rob Williams
Just guessing here, but your answer would be far more helpful if you were to provide the exact NAnt task that merges all of the projects.
Pedro
A: 

I've programmatically using text manipulation created solution files for .vcproj files (but cs/vb would work just the same). It isn't really hard to figure out how to do it if you open up a solution file in notepad or whatever.

Unfortunately I cannot provide the code as it is proprietary.

mostlytech
+1  A: 

Vagif Abilov wrote a wonderful utility that will generate a solution file from project files. It is amazing if you are working for people who don't "believe" in solution files. ugh.

GenerateSolutionFile.exe

Usage: GenerateSolutionFile /p /s [/i includeFilter] [/e excludeFilter]

http://bloggingabout.net/blogs/vagif/archive/2009/08/04/utility-to-generate-visual-studio-solution-file-for-a-group-of-projects.aspx

AllenSanborn
+1  A: 

And I have now updated my utility (mentioned above) to support creation of solution folders: http://bloggingabout.net/blogs/vagif/archive/2009/12/03/utility-to-generate-solution-files-can-now-create-solution-folders.aspx

Vagif Abilov