如何在TFS中用命令行提交更新

首先,我们创建一个通用的bat让它来对某个文件进行获取、签出、复制、签出操作。

postbuild.bat

REM %1-源目录 %2-目标目录 %3-文件名
REM 在生成后事件中写D:\projects\_CommonLibrary\postbuild.bat $(TargetDir) D:\projects\_CommonLibrary\XXX $(TargetFileName)
if defined TFPATH goto runtf
if defined ProgramFiles set TFPATH=%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE
if defined ProgramFiles(x86) set TFPATH=%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\IDE
:runtf
@echo 
'更新开始'
"%TFPATH%\TF.exe" get %2\%3
"%TFPATH%\TF.exe" checkout %2\%3
copy 
%1\%3 %2\%3
"%TFPATH%\TF.exe" checkin %2\%3 /override:reason.txt /noprompt 
set TFPATH=
@echo 
'完成'


这个bat文件可以用在项目的生成后事件中,这样每次编译就可以自动把生成的dll签入到tfs中;同样也可以写一个外部的bat文件使用这样的功能。

例如还有一个copy.bat任务:

net use \\192.168.1.5 /user:用户名 密码

call D:\postbuild.bat D:\xxx\bin\Release D:\yyy\abc.dll

call D:\postbuild.bat D:\xxx\bin\Release D:\yyy\abc.pdb


posted @ 2009-07-08 16:07  网际飞狐  阅读(570)  评论(0编辑  收藏  举报