TFS: using tf to move files
Posted by jpluimers on 2010/09/30
Recently, I had a “server binding” “status=invalid” in TFS when moving quite a bit of files from CVS to TFS.
The most problematic where getting the solution, and a webservice project correctly.
The FAQ on solution binding indicated I should fix my workspace (which is simple: just a root directory), so that was not of much help.
I tried various other things, but in the end, the easiest fix was to:
- rename the directories of the bad solution and project,
- create an empty solution
- create an empty ASP.NET web site project
- then move all of the old files to the new directory structure
Moving files around from within Visual Studio is a tedious process: you can only move one file at a time.
TF to the rescue: it allows you to call perform TFS tasks from the commandline.
Time to automate that with a little batch file.Note that in my case, that
- I renamed the faulty directories from “ProjectName” to “ProjectNameBad”.
- I executed the below batch file from “ProjectNameBad”, making sure tf was in the path.
Batch file:
@echo off setlocal set username=domain\username set password=p@$$W0rd set filename=%~nx1 set sourceDirectory=%~dp1 rem strip backslash set sourceDirectory=%sourceDirectory:~0,-1% rem strip last 3 charachters and make relative directory for /D %%d in (%sourceDirectory:~0,-3%) do set targetDirectory=%%~nd echo "%filename%" echo "%sourceDirectory%" echo "%targetDirectory%" tf move /login:%username%,%password% %filename% ..\%targetDirectory%\%filename% endlocal
Hope this helps a few people.
–jeroen
Leave a Reply