What's the right way to reuse files?

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
vrapp
Posts: 121
Joined: Tue Apr 06, 2004 12:34 pm
Contact:

What's the right way to reuse files?

Post by vrapp » Thu Apr 15, 2004 12:18 pm

Hello:

I have a VB.net project that is already added to the vault and checked out.

Now I want to add an existing module X from my code repository. The repository is located in another folder, and files from it normally are reused by different projects.

What's the best practice to do that? I tried to add the common module X as a single file to Vault and then shared it with the consuming project; but how should I then add X to the solution in VB.Net? there's no action like "add files from source control".


thanks,

Vadim
Vadim Rapp

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

Post by dan » Thu Apr 15, 2004 4:41 pm

This is a Visual Studio issue rather than a Vault issue. Vault handles shared files and shared folders correctly, but Visual Studio doesn't seem to handle them very well, unless I am missing some documentation on MSDN somewhere.

In playing around with it, I did get a single file to be shared into 2 projects, and it seemed to work OK, with a few limitations. Here are the steps I used:

1. Add the solution and projects to source control (they need to be under the same root, or Visual Studio is unhappy), but with the shared file in only one of the projects.

2. Go to the Vault client, and share the file from one project folder to the other project folder you want to re-use it in. Note that the file status there is missing (sharing a file does not automatically do a Get to the working folder where the file was just shared). So, do a Get on the file.

3. Go back to Visual Studio and do an Add Existing Item on the file you just shared from the project you want the shared file in. This appears to work.

4. You can now check the file out in one of the projects, edit it, and check it back in.

5. One caution on this is that the shared file is in two working folders now, not in a single working folder. You will need to edit the file from a single project, because you only want to modify it in one of the working folders at a time. When you check the file in, you will need to do a Get Latest for each share link (or from the Solution file, which would catch all of them) in order for all working folders to be updated correctly.

It might work similarly if you want to share a whole project/folder - I'd be interested to know the results if anyone can get that to work with Visual Studio.

vrapp
Posts: 121
Joined: Tue Apr 06, 2004 12:34 pm
Contact:

Post by vrapp » Fri Apr 16, 2004 11:35 am

Thanks for your response Dan

You said:

Add the solution and projects to source control

meaning, the projects should be within one solution?

That does not seem realistic to me. I have many projects, and they are unrelated. However, they do share components, like "About" form, or module doing registry manupulation, etc.

Having them under one solution would be very inconvenient.
Vadim Rapp

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

Post by dan » Fri Apr 16, 2004 2:39 pm

I think the steps above would still work, even when the projects are not under the same solution. Have you had trouble with getting it to work this way when they are not in the same solution?

vrapp
Posts: 121
Joined: Tue Apr 06, 2004 12:34 pm
Contact:

Post by vrapp » Sun Apr 18, 2004 6:57 pm

dan wrote:Have you had trouble with getting it to work this way when they are not in the same solution?
Thanks, I tried and it worked OK, with maybe one concern:

if the common component is checked out/changed/checked in in its solution, the consumer project does not receive any notification. Unless it performs "get latest version", he won't know that one component was changed.

"Get latest version" can be performed automatically on opening, but it's easy to imagine a scenario when the project is being kept open for long period of time, while common component gets changed by someone else.

Things would be safer if Vault integrated the linked file, i.e. I would link an existing file to the "consumer" project in VB (see the picture), and that would automatically share the file in Vault. The reason is that this way, I have only one phycical copy of the file, with all consumer projects linking it - instead of having multiple copies and relying on Vault in keeping them synchronized. In case of the above scenario, i.e. if the linked file was changed by someone else, Visual Studio would notice it and warn the user of the consumer project: File was changed. Do you want to reload?
Attachments
Capture-04-18-00028.png
Capture-04-18-00028.png (31.83 KiB) Viewed 7999 times
Vadim Rapp

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

Post by dan » Tue Apr 20, 2004 7:25 am

Thanks for the report Vadim. This is more of a Visual Studio issue than a Vault issue - Visual Studio controls the interface and it detemines which files are part of a project or not, so any linking files in multiple projects would have to be supported by Visual Studio first.

I would suggest testing this against SourceSafe or other source control systems. We generally try to work as well as SourceSafe within the IDE, although it is not always possible.

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

Post by dan » Tue Apr 27, 2004 8:07 am

If you are reading this thread, we did some more investigation of sharing projects within Visual Studio, and have a knowledge base article <a href=http://support.sourcegear.com/viewtopic ... 90>here</a> containing the results.

Post Reply