6

我们正在慢慢地将项目从基于旧文件的存储(不要问)转移到 tfs。我们的编码器仍然用于在文件系统中查找代码。

由于我们谈论的是 100 个项目,每个项目都有某种历史,我们必须一个一个小心地移动它们。结果,我们将不得不使用已经存在的文件结构与 TFS 托管文件混合使用一段时间。

为了让我们的编码员生活更轻松,我想在文件系统中为我们移动的每个项目创建一个快捷方式。因此开发人员可以查看项目是否已被移动,如果是,则双击打开直接指向正确项目的 TFS 源代码管理资源管理器。

这可能吗?感谢您的答复。

4

2 回答 2

5

我找到了一个满足我需要的简单解决方案,它基于一个小批量脚本,您必须单击它。即使您仍然可以创建批处理文件的快捷方式,它也不是快捷方式。

这是脚本:

CALL "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86
REG ADD "HKCU\Software\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\Explorer\<GUIDofTFS>" /v "SceMostRecentPath" /d "$/<PathToTfsProject>" /f
devenv /Command View.TfsSourceControlExplorer

事实上,我结合了在不同来源中找到的 2 个想法:

1.用源代码管理资源管理器启动VS

2.操纵Registry以特定路径打开Source Control Explorer

使用该命令devenv /Command View.TfsSourceControlExplorer,您实际上可以启动 VS 并自动打开 Source Control Explorer。不幸的是,没有办法给出一个参数来直接指向你想要的位置。但我注意到 VS2010 似乎保留了最后使用的路径,并在重新启动时重新打开到那个地方。快速研究导致注册表项

HKCU\Software\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\Explorer\058104ed-f0e2-4126-9ccc-0e37e19c4f91\SceMostRecentPath

通过操纵你的值,SceMostRecentPath你可以欺骗 VS2010 打开源代码管理资源管理器,其中包含路径。请记住:您需要替换058104ed-f0e2-4126-9ccc-0e37e19c4f91为 TFS 安装的 GUID。


由于我们都在使用 VS 2010,但安装路径不同,我通过使用 VS100COMNTOOLS 变量动态实现了路径。首先我们设置 TFS 命令行环境:

CALL "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86`

然后我们更改注册表:

REG ADD "HKCU\Software\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\Explorer\[PutYourTfsGUIDHere]" /v "SceMostRecentPath" /d "$/<YourTfsPath>" /f

最后,我们使用 source Explorer 命令对 devenv.exe 进行简单调用:

devenv /Command View.TfsSourceControlExplorer
于 2013-07-23T13:20:44.223 回答
0

Until they're mapped to a local file path, I don't think this is possible. Though there might be an undocumented way to craft a vstfs:///VersionControl/LatestItemVersion/{itemid} link that might work, I haven't been able to craft one that does the trick.

You could create a powershell script that would check for the local mapping, otherwise ask them where they want to put it and setup the mapping, do a get-latest and go from there...

A bit of trickery with the tf commandline should get you pretty far.

  • tf workspaces /owner /collecion /computer to see whether there's a local workspace to the right team project.
  • tf workspace /new /collection to create one if needed
  • tf workfold /map to create a folder mapping, you could prompt them for a target location
  • tf get to fetch the latest sources.

Place the .ps1 file in the folder and when opened check for the workspace, if it's there open the local files in the mapped folder. if it isn't, go through the workspace mapping process by invoking the right commands.

于 2013-07-19T20:31:06.250 回答