D.2 Adding a Solution

If you would like to add a solution to a source control database, you can do so from within Visual Studio .NET using the File Source Control menu. This menu presents two options with which you can add items to source control. "Add solution to source control" allows you to connect to a source control database and add the entire solution, including all the projects and files it contains, to that database. "Add selected projects to source control" allows you to add only projects that are currently selected in the Solution Explorer.

If you select either of these options, you will be presented with the Visual SourceSafe Login dialog box, as shown in Figure D-2.

Figure D-2. SourceSafe Login dialog

If you wanted to connect to a different database than the one displayed, you can select the Browse button and browse to the directory that contains the database to which you would like to connect.

The first time you use source control in any VS.NET session, SourceSafe needs to log you in to the database. In general, it will try to do this automatically so that you don't need to see the login boxif there is a VSS account with the same name as your Windows account, it will normally log in with that name. (If you use this approach, do not make the passwords the same! VSS password security is weak to the point of being optionalfor this style of automated login, you will never be prompted for your VSS password. You are better off leaving your VSS password blank and using Windows security to protect the database files, as described in VSS Help.)

However, in certain circumstances VS.NET will not log you in automatically, for example, when you add a solution to source control or use the File Source Control Open From Source Control... menu option. The reason for this is that the login dialog not only asks you for your credentials but also allows you to choose which VSS database to use. When adding new projects or retrieving projects for the first time on a given machine, it is important to be able to specify which database to use. VS.NET therefore always shows the login dialog in these circumstances. But when you open a local copy of a file that is source controlled, VS.NET logs in silently if it can. (Of course, if your VSS login name is different from your Windows name, you will always get the login prompt.)

Once you connect, a dialog allowing you to select where your solution will go in the SourceSafe database's hierarchy will appear. If you just press Enter, you will get a dialog asking if you want to create a project with the name of your solution. The term project means something quite different to SourceSafe than it does to VS.NET; in fact, a VSS project is most closely related to a solution in VS.NET (and VSS doesn't really have a direct equivalent of a VS.NET project). When you add a solution to a VSS database, it becomes a VSS project, and all of the VS.NET projects and files in the solution will be added to the new VSS project.

If you accept the default location, your VSS project will be created at the root of the VSS database you have connected to. (Otherwise, it will be created wherever you told VSS to create it.) Once you have added your solution, the nodes in the Solution Explorer add icons next to them to indicate their source control status. When you first add a solution, all of the files will be checked in, so every file will have a small lock icon, as Figure D-3 shows.

Figure D-3. Locked items in the Solution Explorer