简体   繁体   English

在 TFS 中添加项目引用会重定向到项目的先前分支版本♦

[英]Adding a project reference in TFS redirects to a previously branched version of the project♦

I have a TFS structure that looks something like this:我有一个看起来像这样的 TFS 结构:

$ $

-MainSoftwareBranch -主软件分支

-Dev -开发

-Main -主要的

-Enterprise -企业

-Project1 -项目1

-Test -测试

-TeamProjectA -团队项目A

-Main -主要的

-Enterprise -企业

-Project1 -项目1

-TeamProjectB -团队项目B

-Main -主要的

-Enterprise -企业

-Project1 -项目1

The end goal of this is that MainSoftwareBranch (MSB) contains all of the software that our company develops.这样做的最终目标是 MainSoftwareBranch (MSB) 包含我们公司开发的所有软件。 When you need a piece of the software, you branch 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.过去某个时候,对我们的分支策略不太熟悉的人将 Project1 直接从 TeamProjectB 分支到 TeamProjectA,而不是从 MSB。 I have tried to fix this and removed the project reference to $/TeamProjectB/Main/Enterprise/Project1 from where it was referenced in TeamProjectA.我已尝试解决此问题,并从 TeamProjectA 中引用它的位置删除了对 $/TeamProjectB/Main/Enterprise/Project1 的项目引用。 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.我从 $/MSB/Main/Enterprise/Project1 分支 Project1 并尝试使用“添加现有项目...”将项目添加到解决方案并浏览到 csproj 文件所在的本地路径。 The project that gets loaded is the one from $/TeamProjectB though.加载的项目是来自 $/TeamProjectB 的项目。 I've removed the source control bindings, both within TFS and manually in the csproj and sln files, but nothing changes.我已经删除了 TFS 和 csproj 和 sln 文件中的源代码控制绑定,但没有任何变化。 It's always "redirecting" my request to open the correct csproj file to the old one that is not valid.它总是将我打开正确 csproj 文件的请求“重定向”到无效的旧文件。

Does anybody have any insight in to what could be causing this bizarre behavior?是否有人对可能导致这种奇怪行为的原因有任何见解?

Project references have nothing to do with TFS.项目参考与 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.现在,如果您的项目恰好位于本地磁盘上的 TFS 工作区中,那么您将拥有与该工作区相关的引用。

Look inside the individual.csproj or.vbproj files to see what the references are to.查看单个.csproj 或.vbproj 文件以查看引用的内容。 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.我怀疑您会发现您有相对引用,例如../../../../SomeProject.csproj,其中相对路径从您的工作区上升然后返回。

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.有几件事要检查...但在您进行任何 TFS/项目结构修改之前,我建议检查所有当前更改(针对所有团队),进行最新以检索所有这些更改,并备份您的整个本地工作区文件夹。

One point I need clarified to fully answer you... what sub-folders are being branched?我需要澄清一点才能完全回答你......正在分支哪些子文件夹? IE would you normally branch MSB/Main to TeamProjectA/Main , or would you branch individual projects, eg MSB/Main/Enterprise/Project1 , Project2 , etc.? IE 您通常会将MSB/Main分支到TeamProjectA/Main ,还是将单个项目分支,例如MSB/Main/Enterprise/Project1Project2等?


First : Check your workspace mappings... in Visual Studio, open the Source Control Explorer.首先:检查您的工作区映射...在 Visual Studio 中,打开源代码管理资源管理器。 There is a workspace drop-down at the top of the window... pick "Manage Workspaces..." and edit your main workspace. window 顶部有一个工作区下拉菜单...选择“管理工作区...”并编辑您的主工作区。

Ideally there is only one working folder, mapping the root of your TFS project ('$' in your case) to a root local working folder.理想情况下,只有一个工作文件夹,将 TFS 项目的根(在您的情况下为“$”)映射到根本地工作文件夹。 If you have more than one working folder, make sure that the second one(s) are not subfolders of the root.如果您有多个工作文件夹,请确保第二个不是根目录的子文件夹。 IE you shouldn't have a separate folder for $/TeamProjectA/Main/Enterprise/Project1 . IE 你不应该有一个单独的文件夹$/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.这是我的第一个猜测,因为如果将TeamProjectB/Project1映射到TeamProjectA文件夹,那么无论您更改引用多少次,您都将始终加载 Team B 的项目。


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).之后的一切都在合并,你只能在直接的父母和孩子之间合并(除非你跳过箍手动搞乱合并......在 9 个国家/地区的可射击进攻)。

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.这意味着只要Project1是从TeamProjectB分支的,您将始终与TeamProjectB相关联......您可以为每个团队和项目修复 TFS 中的引用,但是当您将TeamProjectA合并回MSB时,Project1 将不要与其他所有内容合并到MSB

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.我不清楚会发生什么......该项目只是没有与任何东西合并,或者它合并回TeamProjectB的文件夹。 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.我非常怀疑后者是这种情况,但前者也没有多大意义......我几乎希望 TFS 以某种方式短路。

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.我猜(完整的 WAG)因为您能够将Project1TPB分支到TPA ,所以您没有分支/Main/Main/Enterprise ...我希望答案是TFS不允许您分支到另一个分支的子文件夹。


To Fix This解决这个问题

  1. Merge Project1 back to TPB .Project1合并回TPB Check in.报到。

  2. Merge TPB/Project1 back to MSB .TPB/Project1合并回MSB Check in.报到。

  3. Select TPA/Project1 . Select TPA/Project1项目1。 Go to File -> Source Control -> Branching and Merging -> Reparent .转到File -> Source Control -> Branching and Merging -> Reparent Pick MSB's Project 1 as the new parent.选择MSB's Project 1作为新的父项。 If your branches are done from /Main or /Main/Enterprise , you will have to reparent from whatever the branch root is.如果您的分支是从/Main/Main/Enterprise完成的,那么无论分支根是什么,您都必须重新设置。
    (Note that if TPB/Project1 was not rooted from MSB , this will not be an option... Go to plan 'B') (请注意,如果TPB/Project1不是源自MSB ,这将不是一个选项... Go 计划“B”)

  4. Not sure if you can/need to check those changes in... do a check-in on both TPA and MSB to be safe不确定您是否可以/是否需要检查这些更改...在 TPA 和 MSB 上进行检查以确保安全


Plan 'B' : If that doesn't work, you will have to delete TPA/Project1 and re-branch from MSB .计划“B” :如果这不起作用,您将不得不删除TPA/Project1并从MSB重新分支。 Make sure everything is merged the whole way back to MSB (and checked in) before doing this.在执行此操作之前,请确保将所有内容完全合并回MSB (并签入)。

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 . TFS可能会抱怨重新分支到预先存在的目录(因为它保留了TPA/Project1的删除历史记录)......我不认为它会,但如果是这样,你将不得不使用命令行工具永久删除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.命令是tf destroy ...确保从本地TPA/Project1文件夹运行它,否则 tf 可能无法解析 tfs 服务器/路径。

HTH! HTH!
James詹姆士

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM