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

  • Telerik UI for Blazor Updated

    Progress announced an update to its Telerik UI for Blazor components, targeting Microsoft's open source Blazor framework that lets C# coders create web apps without having to rely upon JavaScript.

  • Infragistics Unveils UI Components for Blazor

    Infragistics, specializing in third-party UI/UX controls and tools, unveiled a new offering targeting Blazor, Microsoft's red-hot open source framework that allows for C#-based web development instead of traditional mainstay JavaScript.

  • AWS Open Sources Tool for Porting .NET Framework Apps to .NET Core

    Leading cloud computing platform Amazon Web Services open sourced the it announced in July for helping users port old .NET Framework applications to the new .NET Core framework.

  • Uno Platform Ports Windows Calculator to Linux

    Uno Platform has ported the famed Windows Calculator, open sourced last year, to Linux as part of a continuing "proof point" effort to demonstrate the reach of what it describes as the sole UI offering available to target Windows, WebAssembly, iOS, macOS, Android and Linux with single-codebase applications coded in C# and XAML.

  • ASP.NET Core OData 8 Preview Supports .NET 5, but with Breaking Changes

    ASP.NET Core OData, which debuted in July 2018, is out in a v8.0 preview that for the first time supports the upcoming .NET 5 milestone release.

Upcoming Events