Symbolic links in TFS 2010 Source Control? - tfs

As far as I know, Team Foundation Server 2010's source control (and prior versions) doesn't support linking (Symbolic links) of files.
Linking (per Visual SourceSafe) was the concept of providing one "hard" file in a folder, and then "linking" to it in other locations - exactly like file system hard links are designed.
Does anyone know if files can be linked at all? I realise it is not a good practice in general, but I have some scenarios where it makes sense.
According to an answer in this thread: Linking TFS source control folder from another TFS project it's not possible, but I can't find a definitive answer.
Closest thing I can find courtesy of Google is a thread on the MSDN forum but it's quite old (2006). I'm pretty much assuming that this is still the answer though (unless anyone knows differently)?

This thread is more recent (2010), about TFS 2008 and 2010:
TFS (2008 and 2010) do not have support for links. There is a server-side extension for TFS 2010 (ie. what VS2010 used for gated checkin) but this sounds like a client-side solution since the link must be converted to a file to be recognized by the client OM.
If you only work with the command line, how about a wrapper tool for some version control operations? For example, the check-in wrapper would convert links to a linktext file and add or replace the existing linktext file before doing the normal check-in. The check-out wrapper would check-out the corresponding linktext file. Note that there will be quite a bit of work since you'll have to wrap many commands.

There seems to be a work-around for this for Linux-based systems.
This page - Applying Unix Filesystem Attributes to Files under Version Control - describes how to use a .tpattributes file text file to store details about file attributes. The article applies to the Visual Studio 2010 edition.
The process is described here: How to work with symbolic link files under Linux/Unix and TFS?. It involves the use of both a .tpattributes file, and a 0-byte file representing the symlink.
There have been some reports of success for this, according to the comments on an updated request to Microsoft for this feature to be implemented in TFS 2015.
In Perforce, symlinks may just be checked-in without having to go through any of this.

It's not possible to make classical links, but it's possible to use branches for simmilar functionality. You can use a branch over folder to make something simmilar as were links. The only drawback is that you still work with branches, so it's necessary to do merges etc. See section "Source Code Sharing" of this document for detailed instructions.

Related

TFS Linked Files Not Found

I have a core project and several sub projects. I link to files in the core project for the sub ones. I righted clicked my csproj and said existing file > add > link. Here is how my project looks:
Here is a picture of my Windows Explorer:
When I check in, I receive this error:
Could not find file C:\Users\joe_a84\Documents\JMASoftware\QuickBooks\Main\Source\Platform Support\NOP\Source\Versions\nop265\Nop265\Module\QuickBooksSettings.cs
The file does not exist there because it is linked. How can I tell TFS that it's a linked file?
There is the following question which states that symbolic links are not supported in TFS 2008 or TFS 2010. Symbolic links in TFS 2010 Source Control?
However, I did find the following ancient blog post which seems to show how to do it for TFS 2005: http://blogs.msdn.com/b/ericlee/archive/2006/07/20/sharing-files-in-team-foundation-server.aspx
That said I would highly recommend that you simply don't do this.
If you really need to share a file between projects then you should be using the branching functionality built into TFS. Typically you don't want just a single code file due to namespace and assembly generation concerns. It is much cleaner, and certainly easier to maintain, by having a separate project for those artifacts that are passed around. This way you either branch the entire assembly project; or just refer to it in it's normal place.
This is a local file level linking by another project. There is only one file at a specific subfolder. Other projects can link to the file via this approach. The problem with this approach is that from TFS viewpoint, you cannot tell if a file is shared by other projects. A good practice will be to keep such files in separate folder with name like Common or Shared etc.
People who have been using File linking across branches in Source Control would have to change their approach quite differently.
Linking between files in TFS is pretty simple. You just open the "Add existing item" dialog and search for the file you want to link in your local workspace. If you would click "Add" now Visual Studio would create a copy of the file in your projects directory. What you do instead is to choose the other option (you have a little drop down menu on the button) and add the item as a link. Thats it.
I faced the same problem. I just did undo on the file which was showing this error in the TFS Pending Changes window and checked-in. This undo did not remove the link that was added in the project. Make sure you do not undo the project file.

Tips and tricks to increase productivity / efficiency with Team Foundation Server

I have to use Team Foundation Server 2010 at my company and I'm not very happy with it.
There are so many features or just default behavior I'd expect from a CVS that TFS seems to lack (compared to svn, git or perforce, which I have experience with), so my question is: which tricks do you know, which hidden features are out there to make TFS easier to use / more convenient?
Perhaps I should elaborate a bit and list what I think could be better:
The default check-in action when associated with a task is "resolve", though in 99% of all check-ins, I only want to "associate" my commit with the task. There's only 1 commit (the last) that "resolves" the task, so why is that the default? Can I change that?
In the check-in dialog, when double-clicking a file, Notepad is launched and shows the contents of the file. Notepad. Seriously? What about the Visual Studio editor? Anyway, I'd like to see the differences to review the changes I've made, not the contents of the file. The diff tool is hidden in a submenu. This might seem trivial, but when I have to check 10+ files it's just annoying to always right-click, open submenu, click to diff.
The diff tool. Merging with it isn't really straightforward, also the conflict detection mechanism is somewhat lacking. The (Tortoise-)SVN / Git merge tools or that of Perforce are way better here.
Speed. Creating a new file, opening a file for the first time, comparing a file with a previous version etc takes forever (that is, 3-10+ seconds). Our TFS server is in-house and has absolutely no load - also why does Visual Studio have to contact the TFS server when I just create a new file (which I might not even check in)? Is there perhaps an option to turn that off?
Readonly files. All files are read-only when checked-in and become writeable when edited for the first time. This is really annyoing when the application crashes because of that. Windows Azure for example modifies a web.config file and fails whenever I check out because the file is read-only then.
These are just the most prominent things that I think are really annoying and unnecessary.
I didn't have the pleasure to branch and merge yet, but from what I've heard so far it won't be very enjoyable as well...
So again: If you know some tricks, settings, featuers that make working with TFS less inconvenient, please share them.
1) is customizable if you reconfigure the work items. (You can also change any combination of fields/states/available values/etc.)
2) is a pain, but if you use the dockable "Pending Changes" window instead then it'll open the file in the editor. I suspect this is a drawback of the Checkin dialogue being modal.
3) you can customize - the option's a little tucked away, but it's on Tools/Options dialogue under Source Control/Visual Studio Team Foundation Server/Configure User Tools. Some third party tools (like BeyondCompare) have pages on their website with details of how to configure them with VS.
4) I've not seen the speed problems, although I do agree about the overhead on creating a file. Not sure if that's configurable.
For the #1
The solution in TFS 2010 is not the greatest one but it works. You need to modify the registry key on your machine as follows:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\Behavior
Change ResolveAsDefaultCheckinAction to False
TFS Power Tools might be a useful extension for you.
http://visualstudiogallery.msdn.microsoft.com/en-us/c255a1e4-04ba-4f68-8f4e-cd473d6b971f
For #2, are you using the "pending changes" window in Visual Studio to keep track of files that are modified? Double clicking on a file there keeps you in the Visual Studio editor.
For #5, make sure Tools->Options->Environment->Documents "Allow Editing of read-only files; warn when attempt to save" is checked.
TFS is hella frustrating. Good luck!
For #2 there is a registry edit you can make so double clicking launches a diff, vote for the answer here - Compare files on double click in Pending Changes view
1, Bash head against wall
2, Say outloud - it's better than SourceSafe
3, Repeat
4, Install git, or mercurial, or just about anything else.

Can TFS Pending Changes show files that are truly changed like SourceGear Vault?

I have been using SourceGear vault for some personal projects and Team Foundation Server for work projects. One thing TFS is missing is a simple feature that Vault has on its check in dialog window.
In the Vault client, you can see if the checked out file changed from the previous version checked in. Here is a screen shot. Notice the column "Details"? That tells you there is a difference. The way this is super helpful is if you have to check out a entire project because you are going to do code re-generation. I'll check out my class library project and then regenerate my CodeSmith templates. Doing this may result in just a few specific files from changing. When I view the pending check-in screen, I see the files that really changed and I can compare to see the impact.
SO... can TFS do this? Maybe there is a 3rd-party tool that will do it for me? Is there a TFS SDK or PowerTool that I have to get. Anyone want to build it?
Select all the files in "Pending changes" window and activate the context menu. Then click "Undo..." > "Undo Changes" > "No to All".
The files without changes will be rolled back.
Per this page, you can run this command from the Visual Studio Command Prompt.
tfpt uu /noget /r *
You'll need to have TFS Power Tools installed for this to work. Also, make sure you browse to the root of your mapped folder within the command prompt (ie - C:\TFS for example).
TFS Power Tools links (if you don't already have it)
TFS Power Tools for 2010
TFS Power Tools for 2012
There is no need to undo the unchanged files, as TFS will notice they're unchanged upon checkin and will only associate the truly changed files. Any files checked out but unchanged are reverted to their last known checked in version and will not be associated with your checkin. It is impossible in TFS (though not very clearly documented) to check in an unchanged file. It will always revert to the previous version if there are no changes.
You can quickly undo your unchanged files by calling 'tfpt.exe uu /r' from the command line (you need to have the Team Foundation Power tools for this) or by using the "Undo unchanged" button in the Pending changes window. This removed any items from the list that are unchanged immediately. So that you can see exactly what you're checking in.
Though it might be that this option is added by the Team Foundation Power Tools or the TFS Source Control Explorer Extensions (which are a must have for every TFS user anyways).
See also:
https://stackoverflow.com/a/2100981/736079
https://stackoverflow.com/a/6387656/736079
https://jessehouwing.net/vsts-tfs-why-i-like-them/
I don't like answering my own questions, but it looks like there might not be a real Microsoft solution out there. For me, this is how I handle the problem at the office using Visual Studio.
Before I re-generate the business objects, I make a copy of the entire folder structure
I check out the entire project or the root generated folder
I start the code generator. Sometimes, I know exactly what is changing, but other times, I might make a lot of changes and I don't want to miss anything. My code generator at work also generates all the SQL files needed to DROP / CREATE stored procedures.
Using SourceGear DiffMerge, I compare the folders of the just generated and the previously backed up folder.
This is pretty time consuming. I never thought of it as a problem until I saw Vault identifying that a file was different on disk from the repository.
Maybe you all can say how you do code generation / regeneration when working with a source control repository.
I work in a corporate development environment where many developers may be working on the same file, and we have TFS as our source control as well. In our document of Best Practices for TFS, we really discourage checking out files that the developers don't intend on changing, that way we naturally exclude files without differences when submitting a changeset.
To answer your question, I normally just look at the "Pending Changes" window and run a Compare on the "changed" files that I'm unsure of--the Compare tool should immediately tell you if your local copy is the same as the server copy. Unfortunately, there's no real workaround other than what I suggested, but I don't see the scenario where I absolutely must check out an entire project branch for editing.

TFS out of sync between local and remote - how to "re-sync"?

I have a Project on CodePlex which is using TFS and I am using the TFS Plugin for Visual Studio. Now I have copied this project and worked on another PC without TFS and done some refactoring. Foolishly, I have then just used copy/paste and manual text editing to merge my changes, expecting that TFS just picks up the changes.
Apparantly, that is not the case.
Here is a screenshot of my local directory:
My Local TFS http://img259.imageshack.us/img259/2897/tfslocal.jpg
Notice how some files are missing the lock symbol - those are missing. If you look at the current TFS Tree on Codeplex, there are some files which do not exist locally anymore, i.e. WikiPlexExtensions.cs in the main folder.
Is there any way to easily tell TFS to compare my local to the remote repository and pick up the changes? I could re-add the local files using "Exclude from local project" and re-adding them, and I could create the "deleted" files as empty files just to delete them, but if I can avoid the manual messing around that would be good as well :)
The easiest way is to exploit VS 2008's "online" feature. Basically you want to set your solution offline, then bring it online while connected to the proper Codeplex server. TFS should figure out the rest.
Feature overview: http://msdn.microsoft.com/en-us/teamsystem/bb898913.aspx
Tweaking the settings by hand: http://blogs.msdn.com/benryan/archive/2008/07/09/using-tfs-2008-power-tools-to-modify-server-s-offline-state.aspx
To compare local and server folders, you can check out TFS Power Tool. After installing it, you can bring up the source control explorer, right click on the server folder and then select 'Compare'. Folder difference window will display the differences. You can also right click on the differences to see available commands such as 'Get Latest' to update your local folder for example. Check out Bryan Harry's blog post on the power tool
I don't think there is an easy fix... What I've done in the past is back up those files that I have edited, then do a "Get Latest Version..." for the files I edited. This should change the files back to being read-only etc... Now, check out the files the regular way and paste the backups you had into the checked out files. Obviously this really only works when there are a couple of files you have edited.
TFS (in Visual Studio) has a "Reconcile" command for this, see Microsoft documentation, or this answer with steps.
BTW: This command may not haven been existing at time of original question, but this question came first when I was searching.

Does any tool exist to help Sync a directory with TFS?

When using TFS with a tool outside of Visual Studio (Specifially ORMS), modifications to the project file to include a new file will not cause the file to be added to source control.
Does anything exist that could potentially say "Warning: You are about to check in change to a project file which include a file which is not versioned"
In addition to Martin's answer, the latest release of TFS Power Toys includes:
"Windows Shell Extension (NEW!)
Allows core version control operations within Windows Explorer without using Team Explorer."
So you may just be able to commit those new files without having to fire up Team Explorer or use an MSSCCI compliant source control client.
Not quite, however you might want to download the TFS Power Tools and check out the command line utility tfpt.exe.
The "tfpt online" and "tfpt treeclean" might be most useful to you when working outside of an integrated TFS client. tfpt online will look for files in your local directory that are not under version control, treeclean will show you files in your local directory that are not under version control so that you can remove then if they are not required.
Good luck,
Martin.
One gotcha I've found using tfpt online is that it doesn't always pick up changes unless you use the /diff switch. That one caused us all kinds of headaches with our automated build until I realised what was happening!

Resources