Vagif Abilov's blog on .NET

Utility to generate solution files can now create solution folders

If somebody wants more from the program you wrote, it’s a good sign. It means that at last you did something useful :-)

Recently my colleague mentioned that the utility that I wrote to generate project solution file should support creation of solution folders. Our development team has in total more than 200 projects, and grouping them within the solution makes a lot of sense.

So I extended the tool, and you can specify number of solution folder levels using “/l” command line switch.

GenerateSolutionFile /p <path> /s <solution> [/i includeFilter] [/e excludeFilter] [/l [*]solutionFolderLevels]

You can specify solution folder levels using an integer number – project names will be split using “.” as separator, and resulting words will be used as solution folder names. Since it’s a good practice to start project name with a name of the company that won’t be useful as a solution folder, it’s possible to skip common project prefix by using an asterisk letter in front of the number specifying the number of levels.

Here are a few examples. If you generate solution file without instructing the tool to create solution folders, you will get a flat structure of projects:

Folders1

If you add a command line switch “/l 1”, then the program will extract a first word from compound project names and create a root solution folder:

Folders2

You can add number of levels with “/l 2” switch:

Folders3

To skip “MyCompany” from solution folder tree add an asterisk when specifying number of folder levels: “/l *1”:

Folders4

And of course you can increase number of levels, here’s how it looks when using “/l *2” switch:

Folders5

Enjoy!

Comments

Filip Hammerstad said:

Nice utility.

One thought comes to mind though: wouldn't this make a good candidate for a Visual Studio Addin instead of/in addtion to a being a console application?

# December 23, 2009 8:47 AM

Vagif Abilov said:

Filip,

Probably yes. Or maybe it can be a template that can be used when people create projects or solutions. In addition to creating a new solution have a choice "Import solution" or "Create solution from folders".

Good idea, I'll investigate how this can be done.

# December 23, 2009 9:50 AM

Allen Sanborn said:

Thanks for sln folder feature. I was just about to sit down and implement that. :)

# January 7, 2010 10:40 PM

Mark said:

Hi, just to make sure. The utility does not analyze the project references to translate them into project dependencies in the final sln file, does it?

Thanks.

# February 12, 2010 11:06 PM

Vagif Abilov said:

Mark. No it doesn't and it shouldn't. Project dependencies are stored in project manifests. If you open any solution file, you will only see a list of projects, not what they reference (it may also contain source control binding information). A solution file is simply a collection of projects.

# February 13, 2010 5:25 AM

Mark said:

Hi Vagif.

I will explain myself. Our projects are not part of ASP.NET application, but rather console/rich client. We do not use project references, rather DLL references. The reason - there are many projects and people tend to create smaller sub-solutions with only a small subset of projects.

Anyway, because the references are to DLL, Visual Studio does not automatically defines build dependencies, meaning developers must define them manually. These dependencies are recorded in the solution file (see ProjectSection(ProjectDependencies) in a solution file). It is tedious and error prone to keep these dependencies up-to-date. It is annoying too, because they map one-to-one onto the project references, but again VS does not deduce the dependencies when the references are not project references, as in our case.

So, I am looking for a tool to recreate solution from projects, which would also recreate the build dependencies by analyzing the project references.

I hope I have explained myself more clearly now.

Thanks.

# February 14, 2010 10:55 PM

Vagif Abilov said:

Mark,

Can you mail me an example of your solution file. Without project files of course - just an SLN file. I will look into it.

You can mail it at vagif dot abilov at gmail dot com.

# February 16, 2010 10:41 PM

Vagif Abilov's blog on .NET said:

I installed to today the latest version of NDepend and gave it a try. Last time I blogged about NDepend

# March 11, 2010 11:20 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Please add 8 and 3 and type the answer here: