Using Team Project Picker to connect to TFS programmatically
The TFS object model exposes a few options for connecting to Team Foundation Server. The Team Project Picker (TPP) is one of the options; the advantage of using the project picker is that the user sees a TFS connection dialog that they are familiar with. The user can specify the TFS Server details and authenticate using this dialog. In this recipe, you'll learn how to use the TPP to authenticate and connect to TFS programmatically.
Getting ready
Follow the steps in the Acquiring TFS object model from the NuGet Gallery recipe to create a project in Visual Studio and add the TFS NuGet packages to this project.
How to do it...
Copy the following code into the
Program.cs
class in the newly created project:// Global Variables private static TfsTeamProjectCollection _tfs; private static ProjectInfo _selectedTeamProject; // Connect to TFS Using Team Project Picker public static void ConnectToTfsUsingTeamProjectPicker() { // The user is allowed...