I have updated TFS check-in policy for StyleCop 4.3.3.0 and also compiled a version for TFS 2010 (now that it has RTM’ed).
The sources and MSIs (one for TFS 2008 and one for TFS 2010) are now available at MSDN Code Gallery.
Enjoy!
I have updated TFS check-in policy for StyleCop 4.3.3.0 and also compiled a version for TFS 2010 (now that it has RTM’ed).
The sources and MSIs (one for TFS 2008 and one for TFS 2010) are now available at MSDN Code Gallery.
Enjoy!
Can you connect to TFS 2010 server using 2008 client? Sure you can! There are couple of gotchas to be aware of, specifically you’d be better off installing an update for TFS 2008; if you do not the following message comes up:
Grant Holliday wrote very detailed post on what needs to be installed and what to do if for some reason you cannot install the update.
However, I wanted to mention this in context of custom tools that use object model. While connecting to TFS 2010 with Team Explorer 2008 will produce the message above (and will require extra steps such as update installation to get TE working), the message won’t appear for your custom tools. In fact, if the connection to TFS 2010 is defined in registry you will connect and may not know the difference from inside of your tool.
Thus if you have custom tools using 2008 OM connecting to TFS 2010, it is your responsibility that the update gets installed correctly on machines with the tools.
When you login to TFS using object model, sometimes it may be useful to get information about logged in user (such as domain, account, email etc.).
In TFS 2008 object model, one would get the logged in user display name, domain name, account name and email as following:
1 TeamFoundationServer server = new TeamFoundationServer("tfsserver",
2 new System.Net.NetworkCredential("domain_name\\user_name", "pwd"));
3 server.EnsureAuthenticated();
4
5 Console.Write(server.AuthenticatedUserDisplayName);
6 // returns user's display name
7
8 Console.Write(server.AuthenticatedUserName);
9 // returns domain_name\user_name
10
11 // AuthenticatedUserIdentity is Microsoft.TeamFoundation.Server.Identity
12 Console.Write(server.AuthenticatedUserIdentity.Domain + "\\" +
13 server.AuthenticatedUserIdentity.AccountName);
14 // returns domain_name\user_name
15
16 Console.Write(server.AuthenticatedUserIdentity.MailAddress);
17 // returns user’s email
In TFS 2010 OM, AuthenticatedUserDisplayName, AuthenticatedUserName and AuthenticatedUserIdentity properties are all deprecated, and instead AuthorizedIdentity property is introduced on Team Project Collection class. The code below makes use of the new property to retrieve logged in user information:
1 TfsTeamProjectCollection collection = new TfsTeamProjectCollection(
2 new Uri(http://tfsserver:8080/tfs/defaultcollection,
3 new System.Net.NetworkCredential("domain_name\\user_name", "pwd"));
4 collection.EnsureAuthenticated();
5
6 // AuthorizedIdentity is Microsoft.TeamFoundation.Framework.Client.TeamFoundationIdentity
7 Console.Write(collection.AuthorizedIdentity.DisplayName);
8 // returns user's display name
9
10 Console.Write(collection.AuthorizedIdentity.GetAttribute("Domain", "default"));
11 // returns domain_name
12
13 Console.Write(collection.AuthorizedIdentity.GetAttribute("Account", "default"));
14 // returns user_name
15
16 Console.Write(collection.AuthorizedIdentity.GetAttribute("Mail", "default"));
17 // returns user’s email
When starting up with TFS 2010 object model, there are few gotchas to be aware of (especially if you did coding for TFS OM 2005/2008 in the past). See my previous post for high-level details:
In 2008 one would establish connection to TFS as follows
1 string[] servers = RegisteredServers.GetServerNames();
2
3 // select one of the servers (in real life combo box?)
4 string serverName = servers[0];
5
6 TeamFoundationServer server = new TeamFoundationServer(serverName,
7 new System.Net.NetworkCredential(userName, password));
8
9 server.EnsureAuthenticated();
In Team Foundation Server 2010 the code becomes:
1 RegisteredTfsCollection[] projects = RegisteredTfsConnections.GetProjectCollections();
2 List<string> servers = new List<string>();
3 foreach (RegisteredTfsCollection collection in collections)
4 {
5 if (!collection.Offline)
6 results.Add(collection.Uri.ToString());
7 }
8
9 // select one of the servers (in real life combo box?)
10 string serverName = servers[0];
11
12 TfsTeamProjectCollection server = new TfsTeamProjectCollection(new Uri(tfsServerName),
13 new System.Net.NetworkCredential(userName, password));
14
15 server.EnsureAuthenticated();
Should be no big surprises considering the changes in 2010 – one server w\projects became multiple projects collections. One thing to be aware of is the change in the arguments you pass to constructor of TfsTeamProjectCollection; in 2005/2008 one was able to pass server name (i.e. “tfserver”) as retrieved by using RegisteredServers class. In 2010 that becomes impossible since the server may contain multiple collections; thus you have to pass full URI (e.g. “http://tfsserver:8080/tfs/DefaultCollection”).
In my previous post, I was talking about using making your custom tools ready for TFS 2010 with SDK. But what about other tools, say you? And not to worry, here you go (and I included not only TFS but VS tools as well):
Enjoy!
So may be now you have finally got your hands on Beta 2 of TFS 2010 (for example, using one of the excellent VHDs prepared by Brian Randell) and it is time to see how your custom applications written for 2008 fare (do not worry, you will be fine!). Here are few notes that should make your life easier.
1. Starting with Visual Studio 2010, SDK does not include samples and documentation. TFS SDK is located on Code Gallery, separately from VS SDK documentation.
2. The backward compatibility of the APIs in 2010 is very good; so if you had an application written against TFS 2008 OM the chances are it will compile and work. You will still have to change references to assemblies to 2010 versions. Additional things to keep in mind
3. New functionality available in 2010 is mostly related to the new features introduced, viz.
So be adventurous and take Beta 2 for a ride! Oh, and most probably for a while you will have heterogeneous environment with 2008, 2010 or may be even 2005 clients etc. This post from WIT team blog will help in figuring out what will and will not work: TFS Server 2010 Beta 2 vs. 2005/2008 TFS client
And should you be in a tight corner (since currently existing documentation is somewhat meager) you might want to head to TFS 2010 Beta 2 MSDN forum.
Update: There is a good summary on Version Control API changes (that I forgot to mention) at Michal Malecki blog: part 1 and part 2
For the benefit of those, who missed the huge announcements in the blogs and are not at the PDC, among other great things unveiled CTP of Visual Studio 2010 is available!
To get maximum fun out of CTP, here are several links
Now, few additional helpful notes
And don’t forget to let guys at MS know, what you think! There is whole set of forums dedicated for the purpose.