Have a look at the Version Task in http://msbuildtasks.tigris.org/
It will enable you to update the assemblyinfo.cs on build.
That still leaves the "how" to identify the branch...
On the risk of having a religious debate on version numbering you can dedicate one part of the major.minor.build.revision part to the branch.
For example, major.minor just follows your 'outside/commercial' version number, build is the buildnumber form TFS and revision 1 indicates your main branch, revision 2 indicates a certain branch.
You can also use on of the other assembly version attributes, like AssemblyInformationalAttribute to store an branch id in it.
I'm not complete up-to-date how you can detect the branch you're on but worst case that is just a matter of getting the current-directory and apply some logic to infer the branch-name.
The output of a tf branch . command should also give you the branch name for a current workspace but you'll need a custom task to extract only the first line.
Not a plug-and-play answer but it might bring you in the right direction.