If you work in a small shop-or are a small shop-you have just as much need of source control as a large one. The good news is that if you use Microsoft tools, you have all you need. Though some criticize Visual SourceSafe (VSS) for its lack of features, it's free and it integrates nicely with Visual Studio (VS). More importantly, it suffices in its most essential role, which is to give you a way to version your source code.
But there's one chore that it does not do very well, and that's adding a new or existing VS solution in a way that matches the structure of your solution. By default, adding a solution to VSS creates a folder structure that's maddening to navigate and impossible to explain. (I speak from 14 years of experience.) In this article, I explain how to fix that problem.Let's say you've just started working on a solution in VS; it's called HelloWorld. So far, you have created two projects, a UserInterface project and a BusinessLogic project, so in your IDE, your solution looks like Figure A:
Meanwhile, in VSS, you have a root folder for all your source code, and in the VSS editor, it looks like Figure B:
So far, so good. What you want to do is add your HelloWorld solution to the SourceCode branch in VSS so that your SourceCode folder has a subfolder called HelloWorld, with subfolders below that for your UserInterface and BusinessLogic projects. That is the structure that would make sense to you and to anyone else who had to work on the project.But the way to get it done is far from intuitive. It starts easily enough-you right-click over the solution name in VS and choose Add Solution to Source Control.... VSS prompts you to enter your credentials, and then asks where you want the project to go and what you want to call it. It defaults to the root of the VSS database and suggests naming the VSS folder <solutionName>.root, as shown in Figure C:
To keep your work organized, you want to put your solution in the SourceCode folder, so you select that as the location, and VSS updates the Location field to match. As shown in Figure D:
What is that extra HelloWorld.root folder for? Hard to tell. Worse, if you remove the .root from the suggested name, you'll get two folders called HelloWorld. In either case, that extra folder does little more than add a layer of confusion, and if you have to hand the project off to a colleague, good luck trying to explain it. Maybe there's a good reason for it, but if there is, I've never found it, and I've never met anyone else who did either.Fortunately, the way to fix it is rather simple, if not intuitive. When VSS asks where to put your solution, delete the Name entirely, so that your Add to SourceSafe dialog looks the one shown in Figure F:
You might think that giving the solution no name would be illegal, but it's not; what it does is avoid creating the <solutionName>.root baggage. Click OK, and VSS will create a structure that matches what you have in your IDE, as shown in Figure G:
Things get much easier from there. If you later need to add other projects to your solution, adding them to VSS will fall in line with expectations. Once you've added your projects in VS, you'll notice little yellow + signs to the left of all the new projects' components in Solution Explorer; VS does not automatically add them to VSS, only to the solution. But it's easy to get them into source control. There's a shortcut menu option to check them in, as you can see in Figure H; just right-click over the project name, and select Check In...:
As you can see in Figure I, VSS will add the new projects right where you expect them to go:
I've discussed the creation of a new VS solution, but the same rules apply to standalone projects and to solutions that you have retrieved from someone else, too. The key is getting the root folder of your solution into VSS the first time without letting VSS add something that doesn't help you. Once you've done that, you're good to go.
Note that these instructions apply to Visual Studio 2005 and 2008, and Visual SourceSafe 2005.