Sharing projects in Visual Studio .Net IDE

A collection of information about Vault, including solutions to common problems.

Moderator: SourceGear

Post Reply
dan
Posts: 2448
Joined: Wed Dec 17, 2003 5:03 pm
Location: SourceGear
Contact:

Sharing projects in Visual Studio .Net IDE

Post by dan » Mon Apr 26, 2004 4:42 pm

A solution file can contain multiple projects, and often the projects within one solution need to be used in other solutions as well, creating the need to share projects in multiple solution files.

Microsoft does not appear to provide instructions on the best practices for sharing projects amongst multiple solutions within Visual Studio, but there are 2 basic ways we found this to work with Vault:

1. Reuse the same working folder for the project in multiple solutions. This is the preferred method, but can fail if the working folder for the project on your local disk contains an incorrect entry in the MSSCCPRJ.SCC file for the location of the project within Vault (see below for more info).

If no solution on your local machine has used the project you want to share, then use the "File->Source Control->Add Project From Source Control" command to get the project from Vault and add it to your current solution. Using this command, you will specify a working folder for the project, and it is this working folder that will be used for all solutions that want to use the project.

If the project is already on your local machine, and is already being used by another solution, then use the "File->Add Project->Add Existing Project" command to load the project into the current solution. If there are no problems, the files in the project will reflect their state in the other solutions that include the project. If there is a problem, all the files will appear checked out, and it is likely that there is a problem in the MSSCCPRJ.SCC file.

If a project was added to source control during the same operation its solution was added, or if the it was retrieved from Vault at the same time the solution was retrieved (via an Open From Source Control command), then Visual Studio misreports where the project resides in Vault (it says it is in the same folder as the solution, which is likely wrong), and this location is stored in the MSSCCPRJ.SCC file, which resides in the same folder as the .csproj file on the local disk (this file is NOT supposed to be in the under source control in Vault).

If this is the case, you can open the MSSCCPRJ.SCC file in Notepad or any other text editor, and change the SCC_Project_Name line to reflect the folder in Vault where the project actually exists.

Unfortunately, once a project is incorrectly added to the solution and it tries to connect to the wrong Vault folder, it is not clear how to fix the solution file, even after modifying the MSSCCPRJ.SCC file to contain the correct mapping. It is easier to simply re-create the solution file and add the projects with correct mappings.


2. Share the projects in Vault (using the Vault Share command), which uses multiple working folders on the local machine, but which resolve to the same underlying objects in Vault, even though they appear in multiple locations within Vault.

This is a more complicated approach, and not necessarily recommended. It also has the problem that if you make an update to one of the shared project locations, a Get Latest from source control must be invoked in all the other shared project locations on your local disk before the file will be updated in that location.

To accomplish this, add the original project to source control, and then share it within Vault to another location (you may want the first project location to be assocatied with the first solution, and the second project location to be associated in the tree with the second project. For example, $/solutions/solution1/MySharedProject would be shared to $/solutions/solution2/MySharedProject. Shared projects must have the same name in all their locations).

After the project is shared within Vault, it can be added to a solution within Visual Studio via the File->Source Control->Add Project From Source Control. Note that the working folder for this project must be a different one from the other shared folders, otherwise the MSSCCPRJ.SCC file problem described above could happen.

Post Reply