I have a TFS structure that looks something like this:
$
-MainSoftwareBranch
-Dev
-Main
-Enterprise
-Project1
-Test
-TeamProjectA
-Main
-Enterprise
-Project1
-TeamProjectB
-Main
-Enterprise
-Project1
The end goal of this is that MainSoftwareBranch (MSB) contains all of the software that our company develops. When you need a piece of the software, you br开发者_JAVA技巧anch it in to your project branch and add a project reference wherever necessary.
At some time in the past, somebody who was not very familiar with our branching strategy branched Project1 directly from TeamProjectB to TeamProjectA instead of from MSB. I have tried to fix this and removed the project reference to $/TeamProjectB/Main/Enterprise/Project1 from where it was referenced in TeamProjectA. I branched Project1 from $/MSB/Main/Enterprise/Project1 and tried to add the project to the solution using "Add Existing Project..." and browsing to the local path where the csproj file is located. The project that gets loaded is the one from $/TeamProjectB though. I've removed the source control bindings, both within TFS and manually in the csproj and sln files, but nothing changes. It's always "redirecting" my request to open the correct csproj file to the old one that is not valid.
Does anybody have any insight in to what could be causing this bizarre behavior?
A couple of things to check... but before you do any TFS/project structure modifications, I recommend checking in all current changes (for all teams), doing a get-latest to retrieve all of these changes, and making a backup of your entire local workspace folder.
One point I need clarified to fully answer you... what sub-folders are being branched? I.E. would you normally branch MSB/Main
to TeamProjectA/Main
, or would you branch individual projects, e.g. MSB/Main/Enterprise/Project1
, Project2
, etc.?
First: Check your workspace mappings... in Visual Studio, open the Source Control Explorer. There is a workspace drop-down at the top of the window... pick "Manage Workspaces..." and edit your main workspace.
Ideally there is only one working folder, mapping the root of your TFS project ('$' in your case) to a root local working folder. If you have more than one working folder, make sure that the second one(s) are not subfolders of the root. I.E. you shouldn't have a separate folder for $/TeamProjectA/Main/Enterprise/Project1
. If you do, delete it and do a get-latest from the root.
This is my first guess, because if TeamProjectB/Project1
is mapped to a TeamProjectA
folder, it doesn't matter how many times you change the references, you will always be loading Team B's project.
Second: You only do a branch one time. Everything after that is merging, and you can only merge between immediate parent and children (unless you jump through hoops to manually mess with merging... a shootable offense in 9 countries).
What that means is that so long as Project1
was branched from TeamProjectB
, you will always be tied to TeamProjectB
... You can fix the references in TFS for each Team and for the project, but when you merge TeamProjectA
back to MSB
, Project1 will not merge to MSB
with everything else.
It's not clear in my mind what WOULD happen... either that project just doesn't merge with anything, or it merges back to TeamProjectB
's folder. I highly doubt the latter is the case, but the former doesn't make much sense, either... I'd almost expect TFS to short-circuit in some way.
I'm guessing (complete WAG) that since you were able to branch Project1
from TPB
to TPA
that you're not branching /Main
or /Main/Enterprise
... I hope the answer is that TFS
won't allow you to branch to a sub-folder of another branch.
To Fix This
Merge
Project1
back toTPB
. Check in.Merge
TPB/Project1
back toMSB
. Check in.Select
TPA/Project1
. Go toFile -> Source Control -> Branching and Merging -> Reparent
. PickMSB's Project 1
as the new parent. If your branches are done from/Main
or/Main/Enterprise
, you will have to reparent from whatever the branch root is.
(Note that ifTPB/Project1
was not rooted fromMSB
, this will not be an option... Go to plan 'B')Not sure if you can/need to check those changes in... do a check-in on both TPA and MSB to be safe
Plan 'B': If that doesn't work, you will have to delete TPA/Project1
and re-branch from MSB
. Make sure everything is merged the whole way back to MSB
(and checked in) before doing this.
TFS may complain about re-branching to a pre-existing directory (because it keeps the delete history of TPA/Project1
)... I don't think it will, but if it does, you will have to use the command line tool to permanently remove TPA/Project1
. Command is tf destroy
... make sure you run it from the local TPA/Project1
folder, or tf may not be able to resolve the tfs server/path.
HTH!
James
Project references have nothing to do with TFS. They are references relative to your local disk.
Now, if your projects happen to be located in a TFS workspace on your local disk, then you will have references relative to the workspace.
Look inside the individual .csproj or .vbproj files to see what the references are to. I suspect you'll find that you have relative references like ../../../../SomeProject.csproj, where the relative path goes up out of your workspace and then back down.
精彩评论