Inside VSTS

Working Offline with Team Foundation Server

Need to work but can't connect to your Team Foundation Server? That's where Team Foundation Version Control comes in.

In a perfect world, you're always connected to Team Foundation Server (TFS) when you need to do your work. However, none of us live in a perfect world. Power outages, server issues, a bad network card -- these are just a few things that could prevent you from accessing the version control system of your TFS.

But there are times, even when you can't connect, that you still need to work. That's where working offline with Team Foundation Version Control comes in.

Offline with TFS 2005
TFS 2005 does not, out of the box, support working offline. However, with the September 2007 release of the Visual Studio 2005 TFS Power Tools and following an explicit workflow, you can achieve offline success.

Step 1: Remove read-only flags from files.
By default, all files located under Team Foundation Version Control are marked as read-only until they're checked out from the server. When you're not connected to the server, you'll have to remove this flag yourself.

You have two possible options, the first being to right-click on the file in Windows Explorer, select Properties and clear the read-only checkbox on the Properties window. However, there's an easier option: If you edit the read-only files in Visual Studio, it will recognize the files as read-only and will prompt you to overwrite them. When this happens, simply click the Overwrite button, and Visual Studio will remove the read-only property and save your changes.

Step 2: Work with the files.
This step is pretty self-explanatory, but there are a couple of caveats you should be aware of. At this point, you can begin editing existing files, adding new files or deleting files. But whatever you do, do not rename any existing files. It's very difficult for the Team Foundation Power Tool to tell the difference between a rename and a delete paired with an add. So to keep things simple, don't rename any files when working offline.

Step 3: Run the Team Foundation Power Tool.
Once you're connected back to your TFS, you'll need to check your changes into Team Foundation Version Control. To do that, "touch" any files that have changed to pend those changes back to TFS. You do this "touching" using the Team Foundation Power Tool (TFPT) "online" command.

From the command line, you can run:

tfpt online

The power tool will scan your workspace for any non-read-only files and pend the appropriate changes to TFS. By default, the power tool won't pick up any deleted files because this can slow down the pending process. If you have deleted files, then you should run the following command instead:

tfpt online /delete

After the tool scans your workspace, it opens the Online window as shown in Figure 1. In this window, you can choose which changes you want to pend to TFS. The changes haven't been sent to Team Foundation Version Control at this point; they've just been marked as pending. You still need to open the Pending Changes window in Visual Studio and click the Check in button to check the changes into TFS.

Figure 1
[Click on image for larger view.]
Figure 1. Use the Online Window to pend changes to Team Foundation Server.

Offline with TFS 2008
In TFS 2008, this power tool functionality has been integrated into Visual Studio Team System. You still follow the same steps as above. If you open a solution that's under version control and TFS is unavailable, you'll be prompted to open the solution offline. The above caveats to editing still apply.

Once Team Foundation Server is available again, you simply right-click on the solution and select "Go Online." This opens the Go Online window (which looks very similar to the Online window in Figure 1), where you choose which changes you want to pend to TFS. Then, as before, using the Pending Changes window, you check your changes into Team Foundation Version Control

Conclusion
Though it's easiest to work with Team Foundation Version Control while connected to it, there may be times when you just can't connect. It's nice to know that with both TFS 2005 and TFS 2008, we have some options for working offline and -- once the server is available -- easily moving our changes back into Team Foundation Version Control.

About the Author

Mickey Gousset spends his days as a principal consultant for Infront Consulting Group. Gousset is lead author of "Professional Application Lifecycle Management with Visual Studio 2012" (Wrox, 2012) and frequents the speaker circuit singing the praises of ALM and DevOps. He also blogs at ALM Rocks!. Gousset is one of the original Team System/ALM MVPs and has held the award since 2005.

comments powered by Disqus

Featured

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events