Reputation: 817
I have two C# projects in TFS and I want to add them to another solution (that is in TFS as well), how to do this correct?
Tried to check out these projects and open the target solution > click "Add" > "existing project" but VS doesn't recognize this projects as they are under Source Control.
All I need now is: 1) Get copies of 2 projects that are already in Source control 2) Add them to my solution 3) Make changes in these projects 4) Check-in changes without affecting the original versions
Upvotes: 2
Views: 2246
Reputation: 23444
Sharing of code between different solutions is an ati-pattern that should be avoided.
If you have two projects that are required in more than one solution you should build and version them independently.
1) Split the two projects out to a new solution and folder structure. 2) Build and version your two shared assemblies 3) package both assemblies as Nuget packages and store on a network share or ProGet server 4) change the references for your two other solutions to use the new Nuget Package 5) create an automated build to refresh the Nuget package as you change the code.
You then have a shared component that you can make deliberate changes and deploy to your shared location. Each solution that takes a dependency will then notify you when the code is changed.
Upvotes: 1
Reputation: 1230
If you want to have two independent copies of you projects, then Askolein solution is your best bet. However, if you want to reference the same projects from many different solutions then I think the following should work (some of it you listed already):
Good luck!
Upvotes: -1
Reputation: 3378
Let's call your two projects your framework
. You should branch your framework and then link in your new solution to the appropriate branch.
In Visual Studio, Team Explorer, browse your code collection
then right click on your framework source root folder and select "branch" .
Then checkin your new branch.
The branched code basically is a full copy of your framework source code. But this copy is logically linked to the original one (for the TFS system). Nothing will be altered in the original one when you alter the branch, but you can merge selected changeset if you wish.
There are many possibilities about how to structure your TFS collection. My advice is to keep your main developping framework code in a Trunk
folder and to have, at the same level, a Branches
folder with all the versions in it. In the image above, there is only one branch made yet (named after a released version of my project to do hot fixes if needed, but this is just an example).
Then, you can merge changes if you want from the branch to the trunk (no obligation, just to avoid manual-error-prone code copy).
Upvotes: 1