Sharing common files between projects

I have a number of projects which share common files so I put a single copy of these into a "Common" folder on my workstation. This folder is at the same level as my projects i.e.

C:\Projects\Common
C:\Projects\ProjectB
C:\Projects\ProjectA etc

So in folder C:\Projects\Common I have Shared.h. Within both Visual Studio 6 projects A and B I have various project specific files which "persist" as e.g.

C:\Projects\ProjectA\MainFrame.CPP, C:\Projects\ProjectB\MainFrame.CPP and in both projects I have Shared.h which "persists" as ..\Common\Shared.h.

Obviously if I modify Shared.h the changes propogate correctly to both projects.

So far so good.

Now I add a similar project structure into my Visual SourceSafe 2005 database by dragging the folders fom explorer onto the "$/" sourcesafe root creating a sourcesafe scenario thus:-

$/ProjectA/Mainframe.CPP
$/ProjectB/Mainframe.CPP
$/Common/Shared.h

In order to ensure that Shared.h is checked out if I modify it in either ProjectA or ProjectB I share the file by Right Click dragging the file Shared.h into ProjectA and ProjectB and selecting Share. This works fine and if I edit Shared.h from within, say, ProjectA it is shown as checked out from within ProjectB. I then check in my changes and this is reflected in both projects.

So far so good again.

Now to the problem at last!

I do a Get Latest (automatic for me when I open a project, say, ProjectB ) and sure enouugh I get the changed version within my ProjectB, as intended. However, when I look in my workstation's C:\Projects\ProjectB folder Shock! Horror! There is another copy of my file Shared.h in addition to the one in C:\Projects\Common.

Surely this is not right. Visual Sourcesafe help says that:-

"Sharing has the following advantages:

  • Makes it unnecessary for each project that uses the shared item to store a separate copy. This conserves disk space on both client and server machines.

  • Because every project to which the item is shared uses the same version of the item, you avoid version incompatibilities that occur when each copy of an item is changing independently within multiple projects."

SO, what am I doing wrong




Answer this question

Sharing common files between projects

  • Thaya

    Any time you are working with local copies, whether pulling down a set of documents from Visual SourceSafe or opening a project from source control inside Visual Studio, you will be getting a local copy. The space savings will only be in the database - potentially big, depending on the file size.


  • Randy R

    Hi Brad,

    Thanks for your response; however I believe that either I am still doing this wrong (i.e. there's a different way to place things into VSS) or that this is a bug or design fault in VSS. I say this for two reasons; one because the help file says "This conserves disk space on both client and server machines." and two because why would I want hundreds of redundant copies of files scattered around my projects, with the attendant risk of reading the wrong one

    regards


  • Mad_Box

    Hi,

    I think the issue here is understanding the difference between what sharing means in Visual Studio compared to what it means in Visual SourceSafe.

    The sharing description you quote is correct, but it only applies to how Visual SourceSafe conserves space. Folders in VSS are also called projects, so it gets a bit confusing.

    Having a shared file in VSS will not keep Visual Studio source control integration from pulling down a local copy of that file for each project you have.

    What it means is that if you make changes to that file from any of the local VS projects, only 1 file in VSS will be updated and that the changes to that file will be available to all the Visual Studio projects that share it


  • Sharing common files between projects