Tip of the Day

Really getting the latest changes with TFS

TFS Source Control doesn’t always get the latest changes. It gets what it thinks are the latest changes (and for the most part it gets it right if you work exclusively in Visual Studio). However, there are times when it gets it wrong and you have to force its hand a little.

So, if you have issues getting latest code then what you need to do is:

  • Right click the branch or folder that is problematic
  • Go to the “advanced” sub-menu and click “Get Specific Version…”
  • Then in the dialog check the two “overwrite…” boxes
  • Finally, press “Get”

At this point VS/TFS will retrieve all the files in the branch/folder selected and overwrite existing files. It will also retrieve files it didn’t already have, even although it thought it had them.

Tip of the Day

How to recover deleted files, folders and branches in TFS

In Visual Studio go to the menu item Tools–>Options…

Then navigate to the Source Control –> Visual Studio Team Foundation Server section.

In that section is a check box that says “Show deleted items in the Source Control Explorer”

Once you’ve ensured that the checkbox is checked, press “OK”

Then navigate to the Source Control Explorer and you’ll see that deleted files, folders and branches are now displayed with a large red cross next to them.

Right click the item you want to recover and select “Undelete” from the menu.

At this point Visual Studio stops responding to input. It displays a wait spinner briefly, but mostly it just looks like it has hung.

When Visual Studio does come back to life you can go to the Pending Changes to see the newly recovered files, folders, or branches.

If you are happy with this change, you can check it in to TFS as normal.

Tip of the Day

Tip of the Day: Getting TFS to remember you each time you open Visual Studio

Because the TFS Server where I work is not on the domain, it will prompt you for credentials each time you log in (unless you’ve previously used the web access and checked the “Remember Me” option). If you don’t want to use the web access portal, you can still get TFS to remember your credentials and not ask you each time you log in.

Go in to the control panel and select “User Accounts”

In the next screen click “Manage Windows Credentials”

In the next screen click “Add Windows Credential”

Then type your details into the form, and press “OK”

You’ll see your new set of credentials appear in the Credential Manager page:

Now when you open up Visual Studio it won’t prompt you for your credentials all the time.

Software Development, Tip of the Day

Tip of the day: Getting Visual Studio with TFS to work offline

Earlier to day our TFS server went down. Visual Studio likes to have a constant connection open to it, but obviously that wasn’t going to happen. Luckily, it is possible to work on a solution with no connection to TFS.

If you were just starting some work…

If Visual Studio was open when TFS went off-line then it won’t allow you to check out any files. If all your files are checked in already, then you can just shut down Visual Studio and then start again. When the solution opens it detects that TFS is gone and offers to open the project in Offline mode:

Go Offline
TFS Go Offline

When TFS is available again you can simply reconnect to the server by selecting the Team?Connect to Team Foundation Server… menu. Once you are connected, you can right-click the solution and select “Go Online“.

You’ll get a dialog that asks to to confirm the files that you’ve changed in the meantime:

Go Online
TFS Go Online

It will then take a few moments for TFS to catch up (I have quite a large solution, so it took about a minute for me) then the files appeared in the Pending Changes window ready to be checked in as normal.

If you were in the middle of something

If you already had files checked out when TFS went offline then this post about converting to offline may be more useful to you.

There is also a Visual Studio extension, if you prefer not having to restart Visual Studio called Go Offline. Once installed, just to to File?Source Control?Go Offline. This may be a more useful solution if you are constantly going in and out of connection with TFS (a mobile broadband connection on a train for example).