How does TFS 2008 pick which Reporting Services instance to use?

One of the painful parts of TFS 2008 install is that you can point (via the msiproperty.ini file) the install at the right machine for your SQL Reporting Services, but not the specific instance on that machine.  It's a bit of a long story as to why that is, but it does lead to the question of "If I have multiple RS instances on the machine I point it to, which one does it pick?"

Here's the logic used:

  • If there are no RS instances on the machine, that's an error (of course)
  • If there's 1 RS instance on the machine, we use that one (of course)
  • If there's more than 1, we look for:
    • If there's one that points to the same DB instance as TFS is being pointed to, we use that one
    • If there's one where the instance name matches the instance name of the database server you pointed to, then we use that one
      • This is useful because many times people will just install all the SQL Server services with an instance name like "TFSINSTANCE", so we Just Work in that case
    • Otherwise, we see if there's a default instance available, and if there is, we use that one
    • Otherwise, we use the first one

There's a good bit of logging in that section of code, so the logs should make it clear what it chose and why.