How often did you choose the obvious choice that came under your mouse? I did it many times! But the obvious and easy choice is not always the best. One of this banal situations is mapping a local path for a TFS Collections/Projects. Hands up who went creating a directory on the C drive and indicating a newly created map as TFS local path! Great, I did the same! However later on, based on experience, I found a way of mapping collections which I believe is better practice. In the following lines I will share my ideas with you. Any suggestion or observation is welcome, so feel free to comment this post.
Why is it not a good idea to just create a folder Projects on a C drive and map everything under it? Well, this PC may be used by others, so this can cause security issues and it can also create confusion and problems if the new user chooses the same directory for mapping.
Based on this information, a good place where to store your code is the user folder. Generally you can find your user folder in C:\Users\%username% on Vista, Windows 7 and 8, C:\Documents and settings\%username% on XP and 2000. What I follow as a rule is to create a top folder called Projects and then inside that folder a sub folder for every collection I have access to. Supposing that my collection is called ACNProject the full path on my PC looks like C:\Users\mario.FLORES\Projects\ACNProject.
However in some cases this can be a problem. If you are using a roaming profile, you will need to do a couple of tweaks. You must exclude this newly create folder from synchronization and in order to be sure about that, you need to check the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ExcludeProfileDirs. You will then find a similar content as on the following image:
Now you need to edit this key by adding at the end the folder name that is situated in Users directory, in this case Projects. Different folders are separated by a semicolon (;). If this became a company rule, you can avoid this step by applying the same changes via a group policy.
In case you do not have the rights for editing the registry and you are still using a roaming profile, a good place where to store the files can be C:\Documents and settings\%username%\AppData\Local which by default is never synced.
Now we are ready to map our collection. Open Visual Studio and Team Explorer.
Click on local path and fill in the above mentioned path. Make sure that you clicked on the collection folder (the $ sign will be visualized as a server folder) and that Recursive check is on. In this way for all the projects in that collection, automatically a folder will be created and mapping will have a recursive effect (all the projects in the collection will be automatically mapped).
Now you will be prompted about getting the latest version of all data from the server, choose No if there are many projects and you need a specific one and then get the latest version of that specific project, otherwise choose yes.
Certainly there can be a case that this approach will not fit, however I consider this a good practice. If you have any suggestions or comments, they are always welcome and I’m always ready to reconsider this task if anything meaningful pops up.