One of the key highlights of Team Foundation Server 2012 is an improved experience when you’re working offline and you would have to wonder: If it’s mentioned as a key feature, how bad was working offline previously?
If you’ve avoid opening a solution under source control in offline mode, you’re extremely fortunate. But for those that have to experience it with Team Foundation Server 2010, you might hear that it’s easier to call it a day than continue working.
Before going further, it’s important to discuss and understand what’s allowed the improvement: the local workspace. A workspace is a critical feature of Team Foundation Server since it’s what allows the differentiation between the changes that have been made against the data stored on the server and your working copy of files.
Prior to Team Foundation Server 2012, the only type of workspace that was available was a server-side workspace which has drawn plenty of criticism since an active connection to a TFS server was essentially required so that synchronization could occur. While the ability to make changes to files was available, it was an extremely tedious and cumbersome process.
The local workspace was introduced with Team Foundation Server 2012 as the default workspace type and it follows the Edit-Merge-Commit system – any changes that are made are noted and then synchronized with the TFS server at check-in.
There are some advantages and disadvantages between the workspace types so you may want to determine how a workspace will be used against a particular project.
Server workspaces have the following advantages and disadvantages:
- Ideal for a large number of files. According to a post made by Buck Hodges, you may want to consider using a server workspace if there are more than 50,000 files involved.
- Compatible with previous versions of Visual Studio. While users go forward with the transition to Team Foundation Server 2012, it’s highly probable that some users will need to continue using Visual Studio 2010 and if this is a case that might occur in your environment, you may want to continue using server workspaces if a workspace needs to be shared.
- Exclusive locks are observed (provided that the asynchronous check-out feature is not enabled).
- All local copies of files are set to read-only. If a solution is opened offline, you’ll be prompted to overwrite changes every time.
- In offline mode, core abilities such as adding, deleting, renaming or undoing changes to a file are not available.
Local workspaces have the following advantages and disadvantages:
- Local files are not set to read-only and changes can be made.
- All normal functionality is available. For example, you can create a new file and it would be recorded as a pending change.
- If a change is made to a file outside of Visual Studio, it will be detected.
- Exclusive check-out locks are not enforced.
- A high number of files may result in performance degradation.
The default setting for a workspace is set to local but if you need to alter an existing workspace or create a new workspace, you’ll find the option under the “Add Workspaces” window.
To get an idea of what using a server workspace is like in offline mode, let’s take a quick walkthrough.
1. To make sure that there was no connectivity to a server, I used the most effective method of guaranteeing no connection – I unplugged the network cable. After verifying that no network connectivity was available, I opened an available solution in offline mode.
2. In a sample application that I had available, I updated two files, About.vbhtml and Index.vbhtml and then saved my changes. Here’s what you’ll see every time a file is saved.
3. I decided to add a new file.
4. To simulate a restored connection to the server, I just plugged the network cable back in and attempted to go online.
Note: The file that was added is not detected as a change.
5. The new file will need to be manually added to source control and then checked-in.
1. For working offline with a local workspace, I used the same high tech method that I used for the server workspace and opened the solution in offline mode. Here’s what the Solution Explorer window looks like:
2. I opened and updated the Web.config file and then saved. I was not prompted to overwrite an existing file that was set to read-only and the change was noted immediately:
I continued working and just made a simple change to the Index.vbhtml file.
3. I reconnected the cable and went online. All of the changes that I had made were recorded as pending changes.
4. I recreated the disconnected environment, added a new file and then went back online. Unlike the server workspace, the change was detected:
While not everyone may find themselves in a situation where working offline is required, the introduction of the local workspace is a much appreciated and welcomed enhancement.