TFS 2010 In Offline Mode

Published on Author Michael

The initial release of TFS did not support having offline clients – meaning it did not support clients that could not connect to the server.  This introduced quite a few problems for folks would might work from home or on the train.  With VS 2008 SP1 (I believe) offline support was partially supported but it required that you use the TFS Power Tools.  With TFS 2010 it is getting a little easier.  Recently I had the need to work offline and I wanted to share the process with others who might be going down this same road because it is not quite obvious.

The Problem

First we need to set the stage for where problems can occur.  If you start up VS and attempt to load a project contained in TFS and TFS cannot be found then VS will prompt you to work in offline mode.  VS only does this when loading a solution. 

So far so good.  If TFS goes offline while a solution is already open though VS will not switch to offline mode.  Instead it’ll keep trying to connect to TFS and then time out.  This is really inconvenient.  It is made worse if you happen to have any files modified, not checked out yet and the appropriate check out options set because you won’t be able to save the files at all.  Really annoying. 

Before continuing let’s be clear about when VS will attempt to check out files.  The options reside in Tools\Options -> Source Control\Environment.  The Checked-in Items – Saving option determines what happens when you attempt to save a file whereas the Editing option determines what happens when you try to edit a read-only file.  The default in both cases is to automatically check the file out.  If TFS is offline then these operations will time out and VS will not allow you to continue.

Making TFS Offline

To get VS to realize that TFS is offline and to force VS into offline mode you have to use the TFS Power Tools that ship external to TFS.  The Power Tools ship with a command line utility called ‘tfpt’.  If you run this command with the ‘tweakUI’ option then you will get a nice little UI for working with TFS.   

(NOTE: The version that ships with TFS 2010 RC does not appear to have the UI available.  I use the version from TFS 2008 instead.)

Selecting the appropriate server and clicking Edit will take you to the server properties dialog.  Within this dialog is an option to force the server into offline mode.  Note that this only impacts VS and not TFS.

Now VS is in offline mode.  This takes effect immediately (even if VS is already open).  Once you set the server to offline mode you still have an extra step to take.  Each file that you want to edit will need to be modified to not be read-only.  You should remove the read-only flag only on those files that you modify.  Doing this will allow you to edit and save files while offline.

Note that TFS will remain offline until you re-run tfpt and uncheck the offline option.

Synchronizing Back to TFS

When you finally connect back to TFS it is important that you synchronize TFS with your changes.  To do this do the following:

  1. Open a command prompt.
  2. Change to the directory where your workspace is mapped.
  3. Run the tweakui command again and uncheck the offline option for the server.
  4. Run the following command: tfpt online

Tfpt will examine the entire directory structure looking for any files that are not read-only.  For each file it will check the file out of TFS if it is not already checked out.  It will also do adds and removes.  You should confirm all the pending changes before checking the files into TFS.  Once you’ve completed these steps you are working with TFS normally again.

5 Responses to TFS 2010 In Offline Mode

  1. This is GRIM. Guy at my work suggested disabling the network, or modifying hosts :
    127.0.0.1 technetium

    Seems to work, as long as you keep an eye on which files you’ve modified.

  2. Thank you for the update ea. In the April 26th version the connections command will bring up a dialog similar to the tweakui from TFS2008. Within this dialog you can select the collection (not the server) and use Edit to toggle online state.

  3. Option to set the server offline on the connections option is available on TFPT 2010. Select server and the click the Edit button. There is an option to force the server to go offline.

  4. The current version of TFS 2010 Power Tools does not support this functionality. You have to use the TFS 2008 version. The power tools don’t care about what version of TFS you are running. You can install the tools on any machine you want.

  5. this solution didn’t work for, i installed Visual Studio 2010 and TFS 2010 power tools as i am unable to install 2008 power tools, in that ‘tweakUI’ is replaced with ‘connections’ option, i followed the steps given even then i am unable to work in offline mode, please suggest me a solution