To start off my blog, I'm going to talk about a feature I've occasionally wished TF Version Control had, and some alternatives that you may find acceptable.
From the documentation for "tf.exe get":
"If you work in a team development environment, Get is the command you use most frequently because getting every file in the current project synchronizes with your team and makes sure that you have the very latest copy of shared work."
What that doesn't mention is sometimes the very latest copy of some code in a dark corner of your workspace will fail to build - horribly. You just did a full sync, built and regret it. You're unwilling or unable to resolve the build issues. If only you could have your old workspace back - you know that built. But how do you get it back? "tf undo" undoes pending changes, not the last sync you performed.
If you didn't plan for this, there may not be anything you can do after the fact. If you have an idea of when you last sunc, you can use "Get Specific Version..." with a date or changeset estimate. Maybe you can find a recent successful build on your builds drop share and relate that back to a changeset/date. If syncing and building doesn't take long, maybe you can use trial and error.
Here are some ideas on preparing for a sync in case you've been bitten by this and are now wary:
@echo off rem Only log Getsif /i "%1" neq "get" goto :RUNTF rem log to internal\tf_invokes.log, relative to this script's path.set LOG=%~dp0internal\tf_invokes.logecho.>>%LOG% rem format the date in .Net's SortableDateTimePattern. Like UTC but using the local timezone.for /f "tokens=1,2,3,4 delims=/ " %%a in ("%DATE%") DO set SDTDATE=%%d-%%b-%%cset SDTTIME=%TIME%if "%SDTTIME:~0,1%" == " " set SDTTIME=0%SDTTIME:~1%set BEGIN=%SDTDATE%T%SDTTIME% echo //[%BEGIN% :: ] [%CD%] [%*]>>%LOG% :RUNTFrem actually run the commandtf.exe %*set TFERRORLEVEL=%ERRORLEVEL% rem Only log Getsif /i "%1" neq "get" goto :end for /f "tokens=1,2,3,4 delims=/ " %%a in ("%DATE%") DO set SDTDATE=%%d-%%b-%%cset SDTTIME=%TIME%if "%SDTTIME:~0,1%" == " " set SDTTIME=0%SDTTIME:~1%set END=%SDTDATE%T%SDTTIME% rem log the end time as well in case its a long running operation.echo \\[%BEGIN% :: %END%] [%CD%] [%*]>>%LOG% :ENDexit /b %TFERRORLEVEL%
@echo off
rem Only log Getsif /i "%1" neq "get" goto :RUNTF
rem log to internal\tf_invokes.log, relative to this script's path.set LOG=%~dp0internal\tf_invokes.logecho.>>%LOG%
rem format the date in .Net's SortableDateTimePattern. Like UTC but using the local timezone.for /f "tokens=1,2,3,4 delims=/ " %%a in ("%DATE%") DO set SDTDATE=%%d-%%b-%%cset SDTTIME=%TIME%if "%SDTTIME:~0,1%" == " " set SDTTIME=0%SDTTIME:~1%set BEGIN=%SDTDATE%T%SDTTIME%
echo //[%BEGIN% :: ] [%CD%] [%*]>>%LOG%
:RUNTFrem actually run the commandtf.exe %*set TFERRORLEVEL=%ERRORLEVEL%
rem Only log Getsif /i "%1" neq "get" goto :end
for /f "tokens=1,2,3,4 delims=/ " %%a in ("%DATE%") DO set SDTDATE=%%d-%%b-%%cset SDTTIME=%TIME%if "%SDTTIME:~0,1%" == " " set SDTTIME=0%SDTTIME:~1%set END=%SDTDATE%T%SDTTIME%
rem log the end time as well in case its a long running operation.echo \\[%BEGIN% :: %END%] [%CD%] [%*]>>%LOG%
:ENDexit /b %TFERRORLEVEL%