Monday, May 03, 2010

What do you need to build VC++ in 2010?

As you probably know, Visual C++ projects in VS 2010 use MSBuild to build. That works fine when you have Visual Studio installed, but can you build your C++ stuff without Visual Studio installed? One could build C#/VB projects with only .NET Framework installed, and prior to 2010, to build VC++ you only needed Windows SDK (that included headers, libraries, compilers and other goodies). So what is the story in 2010?

It turns out the story is similar in 2010 - you will need to have Windows SDK (for C++ specific bits) and .NET Framework 4.0 for vcxproj files. The only fly in the ointment is that Windows SDK is yet to be released (with target date somewhere in June 2010), so for now to build your C++ projects you will need to have Visual Studio installed.

Mirror from my MSDN blog

MSBuild resources reference page

.NET 4.0 and MSBuild 4.0 are out there now, but resources are still ramping up. So as a quick time saver, I have created the biggest most complete no-nonsense 100% satisfaction guarantee MSBuild resources reference page. :) That will be updated as newer content comes online. Enjoy!

Mirror from my MSDN blog.

Sunday, April 18, 2010

StyleCop Check-in Policy updated (v 1.3)

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!

Mirror from my MSDN blog

Saturday, April 17, 2010

TFS2010: Connecting using TFS 2008 object model

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.

Mirror from my MSDN blog

Thursday, April 15, 2010

TFS2010: Who am I? (getting logged in user info)

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

Mirror from my MSDN blog

Tuesday, April 13, 2010

TFS2010: Getting connected in new object model

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”).

Mirror from my MSDN blog

Saturday, January 09, 2010

TFS2010: And the tools are there too!

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!

Mirror from my MSDN blog

Friday, January 08, 2010

TFS2010: And there is an SDK for that!

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

  • You might want to know what version of the server you are working against. This helpful post from Taylor Lafrinere provides the necessary details
  • While 2010 Beta 2 APIs signatures are mostly identical to those in 2008, RC and RTM will have breaking changes that might require changes to your code. This post from Grant Holliday summarizes the changes
  • There were some classes that were made internal, and some classes that were reshuffled to different DLLs. You will know about those when you custom application does not compile
  • If you have used reflection, you are on your own. The chances are that you will have to do some more reflection in order to make it work in 2010 :)

3. New functionality available in 2010 is mostly related to the new features introduced, viz.

  • Project collections (see same post from Grant for the summary)
  • Changes to version control (branches etc. - Microsoft.TeamFoundation.VersionControl.Client namespace has it all; also see an update below)
  • Hierarchical work items (see a primer on the API from Ewald Hofman)
  • Test related work items in MTLM (see another primer from Ewald)

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.

Mirror from my MSDN blog

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