TFS

Workspaces in TFS, Best practices

How to create new workspace in TFS, how to use them and how to check out projects from TFS?

If you have TFS (Team Foundation Server) installed, Open Visual Studio 2012 and go to

  1. File > Source Control>Advance>Workspaces. A dialog popups. Click add workspace, type in name of the new space
  2. Select the workspace and click edit button. Set the local path as well are remote path.Best practice is, Remote path should be the root folder where all projects are sitting. Local path should be empty folder preferably sitting in the root folder such as c:\Projects\
  3. The local folder has been mapped. Now TFS will ask you to check out the project (a dialog box will popup). Select no at this point. Selecting yes will force to check out everything in the root folder which you may not want.
  4. In Visual Studio 2012, go to Team Foundation Server, click on home button then “Explore Source Code”. Now select the folder you want to check out and select get latest. You can select a folder embedded in the root folder. That will check out the folder you selected as well as its complete path. This way your local copy of the repository has the same exact path as on the Server.

Workspaces is a wonder way to fix issues in builds. For example you have a workspace which you are working in. Suppose someone checked in the code that broke the build. Now you can create a second workspace as guided above and check out the same project. Open the new project in a new Visual Studio. You will spot the bug right away without breaking your existing code (which might work fine).

TFS is blind of changes

TFS is blind of changes if you have not synched upto the latest version.

Example you worked on page A. You went on vacation. A college worked on page A when you were out. You came back. You know that your college updated Page A. You select the Page A and compare against the latest version. It does not show any modification. This should because the TFS has a latest version which has update contents.

If you select the history of the file, it will correctly show the latest versions, including the modification by your collegue. But the TFS is simply blind of any latest version that you have not synched upto. It does how the red check mark (for modified files), it just shows the contents are the same which aren’t.

Add files to TFS from folder

TFS (Microsoft Team Foundation Server) does not come up an addon that allow to add file directly from the folder. But you can do that same in Visual Studio.

Start Visual Studio, go to Team Explorer (you do not need to open any project). On the top drop down, click home. Then click the link on the top “Source Control Explorer”. Browse to the folder where the file exists. Right click on free space and click “Add items of Folder”. A dialog will show up. This will show all those files which are not check in. Select the files and click ok. Do not forget to commit the changes to TFS.