如何使用tf在脚本中从TFS导出某个标签下的文件?
我需要一个批处理脚本,它使用 tf 检索 TFS 中标签的目录结构,类似于 svn 导出,同时又不会弄乱我当前的工作工作区。
这就是我设法想出的:
tf workspace /new TemporaryWorkspace /noprompt
这将创建一个新的工作区,但具有以下工作文件夹: $/: C:\ (考虑到我从 C: 运行了命令)
这不是我想要的,但“tfworkspace/new”似乎不允许指定映射,所以我运行此命令来删除默认映射:
tf workfold /unmap $/ /workspace:TemporaryWorkspace
然后创建一个我想要的映射。
tf workfold /workspace:TemporaryWorkspace /map $/Project/Path C:\Temp\Path
将当前目录更改为本地工作文件夹(我不知道选择当前工作区的另一种方法)
PUSHD C:\Temp\Path
现在我终于可以检索标签并用它做我的事情了。
tf get /version:LMyBeautifulLabel
现在清理。
tf workspace /delete TemporaryWorkspace /noprompt
返回
POPD
所有这些对于我卑微的目的来说似乎有点太麻烦了。有没有更简单的方法?
谢谢。
I need a batch script that uses tf to retrieve the directory structure for a label in TFS, something like the equivalent of svn export, while not messing up with my current working workspace.
This is what I managed to come up with:
tf workspace /new TemporaryWorkspace /noprompt
This will create a new workspace, but with the following working folder:
$/: C:\
(considering that I ran the command from C:)
This is not what I want, but "tf workspace /new" doesn't seem to allow specifying the mapping, so I ran this to remove the default mapping:
tf workfold /unmap $/ /workspace:TemporaryWorkspace
then this one to create my desired mapping.
tf workfold /workspace:TemporaryWorkspace /map $/Project/Path C:\Temp\Path
Change the current directory to the local working folder (I don't know of another way to select the current workspace)
PUSHD C:\Temp\Path
Now I can finally retrieve the label and do my stuff with it.
tf get /version:LMyBeautifulLabel
Now the clean up.
tf workspace /delete TemporaryWorkspace /noprompt
Go back
POPD
All these seems a bit too cumbersome for my humble purpose. Is there a simpler way?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,您需要使用正确的工作文件夹映射创建一个工作区,然后运行
get
。没有单行别名可以为您设置这一点。您也许可以使用不需要删除的正确工作文件夹映射创建一个寿命较长的工作区,但如果您经常使用此工作流程但使用不同的标签或在不同的位置,则可以创建一个新的临时工作区每一次都可能是最有意义的。
这里最好的解决方案是创建一个执行此工作流程的命令脚本,或者使用 tf 命令行客户端鲜为人知的脚本功能。您可以使用以下方式运行
tf
脚本:或简单地使用:
从标准输入读取。
Unfortunately, you will need to create a workspace with the proper working folder mappings and then run the
get
. There's no one-liner alias to set this up for you.You may be able to get by with creating a longer-lived workspace with the proper working folder mappings that you need not delete, but certainly if you're using this workflow frequently but with different labels or in different locations, creating a new temporary workspace each time probably does make the most sense.
Your best solution here is to either create a command script that executes this workflow or use the little known script functionality of the
tf
command line client. You can run atf
script by using:or simply using:
to read from standard input.