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.
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.
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:
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:
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).