Mike Parks

"If you want to be the best, you've got to work with the best"
posts - 26, comments - 101, trackbacks - 0

My Links

News

Archives

Tuesday, September 15, 2009

TFS Auto Shelving

 


For Visual Studio 2010 / TFS 2010 please see:  http://geekswithblogs.net/MikeParks/archive/2010/05/12/tfs-auto-shelve---new-visual-studio-2010--tfs.aspx


In one of our meetings the other day a few developers on our team asked if there was an Auto Shelve feature in TFS to shelve their pending changes automatically each night. I couldn't find anything in the Visual Studio 2008 IDE that allowed us to do this.  After some research, I did find a work around.

Basically, I just created a batch file that uses the Visual Studio 2008 Command Prompt to run tf shelve on the highest level folder of your local TFS workspace mapped on your C drive. It uses tf shelve to create a TFS shelveset called "Daily Backup - Your Name".  It will replace that same shelveset every day with all your current changes (or however often you have the Windows Scheduled Task runs).

This way, you will always have a backup copy of your daily changes. It's always nice to be on the safe side, even if you think you don't need it.  A few developers have had their machines crash on them and had to have the machine re-imaged. This would have came in handy back then.  I could have built a custom TFS add-in or app, but I figured this was extremely easy to just use a batch file and windows task.  Anyway, to set this up, just follow the steps below:

  1. Open notepad and paste these two lines in:

    call "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"
    tf shelve "Daily Backup - YOUR_NAME" /noprompt /replace > "C:\TFSBackupLogFile.txt"
  2. Edit the title in the 2nd line to include your name and edit the path at the end of the 2nd line to map the log file
  3. Save the file to your desktop (or anywhere you'd like) and name it TFSBackup.bat
  4. Click Start > Control Panel > Scheduled Tasks > Add Scheduled Task
  5. Walk through the scheduled task Wizard and point it to the TFSBackup.bat file you created
  6. Set the Task to run daily at whatever time you want
  7. Run the task to make sure it runs executes the bat file successfully and check TFS to make sure your shelveset was created

You can view TFS Shelvesets by opening Visual Studio > File > Source Control > Unshelve Pending Changes.

 

 

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Tuesday, September 15, 2009 11:14 PM | Feedback (5) |

Powered by: