![]() |
Platforms, Frameworks & Libraries »
.NET Framework »
How To
Intermediate
Slow VS.NET Builds? Migrate Your (Developer) Solution to Ultra!By TSzatkowskiMaking developers more productive by reducing the amount of code in their *.sln solutions. |
C#, VB, Windows, .NET, Visual Studio, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||
The issues discussed in this article refer to large, or very large Visual Studio .NET solutions, consisting of dozens of projects. This is often the case in teams where a team of programmers work on the same product. Usually, all the people deal with the same SLN solution file, which keeps growing in size (in the sense of number of projects, number lines of code, number of classes etc.).
In this article I will try to explain why having too many projects in a developer's solution is generally not a good idea. Then I will present the way to change it and, consequently, gain more time for productivity.
Please note that I don't give hints on optimizing production builds (master solutions) here � I just describe how to adjust these solutions to the needs of every developer in the team.
It is essential for the reader to distinguish between assembly references and project references in Visual Studio .NET.
A developer can decide over the type of reference when executing Add reference... command in Solution Explorer of Visual Studio .NET.
After clicking on Add Reference... command, an Add Reference dialog appears and a type of reference can be chosen. It can be either:
Adding a project reference is just choosing one of the projects that exists in a solution. Adding an assembly reference is just selecting a DLL file existing on disk (representing a proper .NET assembly). Certainly, there are classes that can't be referenced by means of project references, since nobody gives access to CSPROJ projects (and the source code) for them � for example, this is the case with all the .NET Framework classes.
The difference between both types of references can be summarized by the following table:
| Assembly reference | Project reference | |
| Free access to referenced source code (in order to view details or modify something) | No | Yes |
| Referenced source code is rebuilt every time a solution is rebuilt (Rebuild Solution command is evoked) | No | Yes |
| Referenced source code is built every time a solution is built (Build Solution command is evoked) | No | Only if modified or in the first Build Solution) |
As you can see, there is a speed vs. flexibility trade-off between the two types of references.
As Visual Studio .NET solution grows in size, some problems arise:
(Referring to my professional experiences as a software developer: once I worked with a Visual Studio .NET solution that consisted of approximately 100 projects, which took 1 minute to load and 10 minutes to rebuild.)
Ultra is a name for a set of guidelines which can help significantly reduce the number of projects referenced by a Visual Studio .NET solution, while staying up to date with the master builds. Ultra is not a name for a technology or a product.
Just to make the text more concise, I assume the following:
As an example, look at the following UML diagram:
As you will see, Ultra can be described as the idea of:
The steps below define precisely how to turn the idea into reality.
Before continuing with the following steps, please create a backup copy of your solution. This is highly recommended!
The solution U should be divided into two parts:
Please note: no removals so far!
For every project in L (the set of projects that you have decided to leave):
For every project in L, note its references.
From a practical point of view, you can just grab screenshots like this:

In the example: project WebcamTest references WebCam_Capture.
For every project in R:
For every project in L, restore its missing references by creating new assembly references to projects in R (if applicable). You should know what the correct references are, since you have noted them in step 4. The newly added assembly references should point to DLL files in master folder F - if F is empty, just rebuild the master solution S.
That's it ! Your first Ultra solution should now compile and run.
During our work with solution U, it won't take too much time to make some of the referenced assemblies outdated, since other developers send their modifications to the source control. This is why master folder F has been introduced � in order to work with the latest state of the solution, it is enough to:
If the master build succeeds at our computer, it should update assemblies in folder F. After opening our Ultra solution U in Visual Studio .NET, we should work with the latest state of the solution.
One might ask: "Wait a minute! It seems there is no possibility to predict all the necessary projects in advance. What if, say, I need to modify the set of projects in U a little bit?"
Well, I claim Ultra can be flexible. It is easy to add a new project P to Ultra � just consider the following:
To remove a project P from U, do the following:
P assembly file in master folder FOne of the issues that might require special attention is adding new files to projects. For example, let's say I have two projects in my source code repository:
and I work with Ultra.
Now, if I add a new item to that solution,
say, a class, the addition won't be done automatically in the master solution. This might mean: if I don't do the same in the master solution (but, say, send the code to the source control server), the production build will get broken.
Now imagine the following scenario:
When I open ProjectA.csproj, Visual Studio .NET won't make it possible to create the same folder again (A file or folder with the name 'NewOne' already exists on disk at this location. Please choose another name. ...) The only way to achieve the goal is to modify ProjectA.csproj manually (in any XML file editor). Using the example above, the following line should be added:
<Compile Include="New classes\NewClass.cs">
in the appropriate section of ItemGroup XML.
Even gigabytes of RAM and lots of GHz in CPU won't help too much when dealing with overgrown solutions. Removing nearly 80% of the projects from a large solution can make the difference, save your time and money � no need for hardware upgrades, really! The migration can be done once. Many "Ultras" can even coexist at the same time (used by you or other folks in the team) ! I believe the potential problems are identified and relatively easy to handle. Now, all you have to do is just try it yourself and see the everyday benefits of gaining some precious time.
| You must Sign In to use this message board. | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 12 Nov 2007 Editor: Deeksha Shenoy |
Copyright 2007 by TSzatkowski Everything else Copyright © CodeProject, 1999-2009 Web13 | Advertise on the Code Project |