Professional Team Foundation Server 2013 (2013)
Version Control in Heterogeneous Teams
What's in this chapter?
· Understanding heterogeneous teams
· Working with Xcode
· Working with Eclipse
· Working from the command line
What Are Heterogeneous Teams?
Heterogeneous teams are ones that comprise team members who focus on different technologies, languages, and tools. A typical example of a heterogeneous team is a team that maintains an application with a web front-end written in ASP.Net MVC, an iPad app, a Windows Phone app, and an Android app sitting on a business logic layer composed of RESTful APIs written in C# that calls out to Java web services. The system may also create batches of data as CSV files that get pushed over FTP to a folder where a COBOL application on the mainframe picks them up at a specified time each night for further processing.
Inside this team, you have Microsoft .NET developers, Java developers, COBOL developers, Objective-C developers, and C++ developers all needing to work together to create a seamless application suite. Typically, each group would have its preferred version control tool that would integrate with its toolset.
Working Together Seamlessly
Managing changes in separate version control repositories based on the technology in use means that creating builds and gathering check-in data, as well as coordinating changes, become much more complex. Team Foundation Server offers these kinds of teams the ability to coordinate their version control tooling by offering two types of version control repositories that will work across all of these platforms.
Team Foundation Version Control allows teams that want to use a centralized version control system to have an integrated experience regardless of platform. When working on a Windows operating system, the team members can use Team Explorer. Team members that use the Eclipse IDE can install the Team Explorer Everywhere plug-in to gain many of the benefits derived from Team Explorer.
Team members working on iOS, Linux, or Solaris can still install Eclipse with Team Explorer Everywhere to access Team Foundation Version Control. If the team member is working on a machine without a graphical user interface, Team Explorer Everywhere ships with a command-line client that will let you perform all of the version control functions from a command line.
Team Projects based on a Git repository allow any team member across any platform and using any IDE to utilize Team Foundation Server as their remote version control repository. Many IDEs are able to integrate with Git out of the box, such as Apple's Xcode, and there are a number of Git implementations that allow use across Windows and non-Windows platforms alike.
Developers of iOS applications usually use Apple's Xcode development environment to support their application development efforts. The Xcode IDE has built-in support for Subversion and Git version control repositories. Because Team Foundation Server has the option to create a team project with a Git version control repository, Xcode developers can easily connect to a Git-based team project using the built-in functionality.
Using a Git-Based Team Project
To connect your Xcode IDE to the Git repository in your team project, you will first need to clone the team project's repository. Start by opening up Web Access and navigating to your team project. Click on the Code link to bring up the source control page. If you have an empty repository, you will see a page similar to Figure 8.1.
Figure 8.1 Empty Git repository in Web Access
At the bottom of this page, you will see a section titled “Push an Existing Repository.” There are two git commands in this section. The git remote command has a URL argument. You will need this URL to connect from Xcode.
If you already have code in the repository, you will need to look to the right side of the page. There you will see a Clone link. Click this link to display the URL needed to pass to Git to clone your repository, as shown in Figure 8.2.
Figure 8.2 URL to clone an existing Git repository
Once you have that URL, you open your Xcode IDE and click on the Check out an existing project link on the Welcome to Xcode screen as shown in Figure 8.3.
Figure 8.3 Welcome to Xcode dialog box
In the Check Out dialog box, enter the URL you copied from Web Access into the Repository Location text box, as shown in Figure 8.4.
Figure 8.4 Set remote repository location
Xcode may prompt you for your credentials, as shown in Figure 8.5. Enter your user name and password and click the Next button.
Figure 8.5 Enter repository credentials
Alternate Credentials for Visual Studio Online
If you are attempting to connect to a Git repository hosted on Visual Studio Online, you will need to configure Alternate Credentials on your account. Some applications that work outside the browser use Basic Authentication credentials and other applications have problems with user names that are e-mail addresses. To support these tools, Visual Studio Online lets you configure alternate credentials. For more information, see http://aka.ms/VSOAlternateCredentials.
Once Xcode has found the repository and verified your credentials it will ask you to select a directory in which to check out the project. Select a folder and click the Check Out button, as shown in Figure 8.6. When this step completes, Xcode will open with your project loaded.
Figure 8.6 Enter repository credentials
Using a TFVC-Based Team Project
What happens if the organization has decided to use a Team Foundation Version Control (TFVC)–based repository for its team project? In this case, Xcode developers have two options, they can create their own team project with a Git repository, or they can use Git locally and then push to the TFVC repository using a tool called git-tf. Git-tf is a Java-based, open source, cross-platform, command-line tool that serves to bridge the gap between local Git repositories and Team Foundation Version Control repositories in a team project.
Installation is as simple as extracting the contents of the downloadable zip file to a local folder, adding the extracted folder to your PATH environment variable, and ensuring that java.exe is also in your PATH.
Because of the differences between Team Foundation Version Control and Git, we recommend that the team select a single Git repository to interact with the team project's repository. So in my team, I would use git tf clone to clone the TFVC repository from Team Foundation Server. I would then Push to a shared Git repository. The rest of my team would use git clone to clone the shared Git repository, and we would develop our application there. When we are done, I would Pull from the shared Git repository and then commit all of the work to TFVC using git tf checkin. Nobody else in my team needs to interact with the TFVC repository.
For more information and typical workflows on the git-tf tool, see http://gittf.codeplex.com.
Back in 2009, Microsoft acquired a company that created a Team Foundation Server extension for the Eclipse IDE called Teamprise. That product was later renamed to Team Explorer Everywhere (TEE) and currently includes an Eclipse plug-in, a cross-platform command-line client, and a Java SDK for building custom tools that access TFS. The team responsible for it has also built a set of Team Build extensions that allow Team Build to compile Java applications that use Ant or Maven.
Team Explorer Everywhere's Eclipse plug-in allows team members working on non-Microsoft technologies to interact with their Team Foundation Server. It is written in Java and runs on the operating systems and Java versions in the following lists. It supports IDEs that are based on Eclipse 3.5 to 4.3, including Rational Application Developer.
· Team Explorer Everywhere Supported Operating Systems
· Windows 8.1 (x86 and x64)
· Windows 8 (x86, x64)
· Windows 7 (x86, x64)
· Windows Vista (x86, x64)
· Windows XP (x86)
· Linux with GLIBC 2.3 to 2.11 (x86, x86_64, PowerPC)
· Mac OS X 10.8+ (Intel only)
· Solaris 8 to 11 (SPARC,x64)
· AIX 5.2 to 7.1(32- and 64-bit)
· HP-UX 11i v1 to v3 (PA-RISC, Itanium)
· Team Explorer Everywhere Supported Java Versions
· Oracle Java 1.5+ or IBM Java 1.5+ on Microsoft Windows
· Apple Java 1.5+ on Mac OS X
· Oracle Java 1.5+ on Linux or Solaris
· IBM Java 1.5+ on Linux or AIX
· HP Java 1.5+ on HP-UX
Team Explorer Everywhere has a look and feel that is very similar to the look and feel of Team Explorer for Visual Studio. Because of this design similarity, almost all of the workflows are similar between the two Team Foundation Server clients. As such, most of the help and tutorial documentation that applies to Team Explorer applies to Team Explorer Everywhere.
One of the new features of Team Explorer Everywhere 2013 is that it exposes functionality from both TFVC- and Git-based team projects right in the plug-in in a manner similar to Team Explorer.
Installing Team Explorer Everywhere
The easiest way to install Team Explorer Everywhere on a computer with Internet access is to use the Microsoft update site. Simply open Eclipse, navigate to the Help menu, and click Install New Software. When the Install dialog box appears, click the Add button, as shown in Figure 8.7.
Figure 8.7 Available software page in the Install dialog
The Add Repository dialog box will appear. In the Name field, enter something memorable like “Team Explorer Everywhere” and set the location of the update site to http://dl.microsoft.com/eclipse/tfs, as shown in Figure 8.8.
Figure 8.8 Add Repository dialog box
Click the OK button, which will bring up the list of features in the Install dialog box. Here, select the TFS Plug-in for Eclipse check box, as shown in Figure 8.9.
Figure 8.9 Feature selection in the Available Software page in the Install dialog
Choose the Next button to download the metadata for Team Explorer Everywhere. When it finishes downloading, the Install Details dialog box will be displayed, as shown in Figure 8.10. Review the add-ins to be installed and click the Next button.
Figure 8.10 Install Details dialog box
In the Review Licenses dialog box, select “I accept the terms of the license agreements” and click the Finish button, as shown in Figure 8.11. Eclipse will now download and install Team Explorer Everywhere. When the installation is complete, you will need to restart Eclipse.
Figure 8.11 Review Licenses dialog box
Once Eclipse is restarted, you can access Team Explorer Everywhere's windows by selecting Window Open Perspective Other, as shown in Figure 8.12.
Figure 8.12 Open Perspective menu in the workbench
In the Open Perspective dialog box, select Team Foundation Server Exploring and click OK, as shown in Figure 8.13. The Eclipse workbench now has a section holding Team Explorer, as shown in Figure 8.14.
Figure 8.13 Open Perspective dialog box
Figure 8.14 Team Explorer Everywhere in the workbench
Connecting Team Explorer Everywhere to Team Foundation Server
Now that you have Team Explorer Everywhere installed into Eclipse, you need to connect it up to your Team Foundation Server. Start by clicking on the Connect to Team Foundation Server link in Team Explorer, as shown in Figure 8.14. In the License Agreement page of the Add Existing Team Project dialog box, click the “I have read and accept the terms in the License Agreement” and click the Next button, as shown in Figure 8.15.
Figure 8.15 License Agreement page
In the Team Project page, click the Servers button, as shown in Figure 8.16. In the Add/Remove Team Foundation Server dialog box, click the Add button. In the Add Team Foundation Server dialog box, enter the name of your Team Foundation Server in the Name or URL of Team Foundation Server text box, as shown in Figure 8.17, and click OK.
Figure 8.16 Team Project page
Figure 8.17 Add Team Foundation Server dialog box
Back in the Add/Remove Team Foundation Server dialog box, click Close. Now you can select your Team Foundation Server in the server drop-down, which will load the available team project collections. Select your team project collection to load the collection's team projects, as shown in Figure 8.18.
Figure 8.18 Team Project page with team project selected
To complete the process, click Finish. This will finalize the connection between Team Explorer Everywhere and Team Foundation Server. Your IDE is now ready to work with Team Foundation Server, as shown in Figure 8.19.
Figure 8.19 Team Explorer Everywhere connected to TFS
Using Team Foundation Version Control
Once Team Explorer Everywhere is installed and connected to your TFVC-based team project, you can click the Source Control Explorer link in TEE to open the Source Control Explorer window, as shown in Figure 8.20.
Figure 8.20 Source Control Exploresr in Eclipse
Store an Existing Eclipse Project in TFVC
One of the first things you have to do is take the source code for your project and place it into your team project. To do this you will have to have your project open in Eclipse and TEE connected to TFS.
Start by right-clicking on your project in Package Explorer and selecting Team Share Project from the context menu, as shown in Figure 8.21.
Figure 8.21 Share Project menu
This will bring up the Share Project Wizard. Select Team Foundation Server from the repository plug-in list, as shown in Figure 8.22, and then click Next.
Figure 8.22 Selecting the repository plug-in
When the Server Location step appears, navigate to your team project. Note that the Eclipse project name is appended to the selected folder in the Project folder path text box, as shown in Figure 8.23. Once you have your path selected, click Next.
Figure 8.23 Selecting a server location
Review your configuration and then click Finish, as shown in Figure 8.24. This will create a set of pending changes (adds) in version control, as shown in Figure 8.25.
Figure 8.24 Confirmation pane in Share
Figure 8.25 Pending Adds in Source Control Explorer
In the Pending Changes pane, enter a comment and then click the Check in button as shown in Figure 8.25 to commit your changes to the repository. Congratulations, you have successfully shared your Eclipse project in Team Foundation Server.
Import an Existing Eclipse Project from TFVC
Now that you have your source code available, you will need to bring it into Eclipse. This is typically done when you get a new team member or when you have to support a codebase that hasn't been touched for a while. In either case, you want to start by importing your project code into Eclipse.
Start by selecting File Import… to open the Import Wizard's Selection pane. Expand the Team node and select Team Foundation Server as an Import Source, as shown in Figure 8.26. Click Next.
Figure 8.26 The Select pane in the Import Wizard
In the Projects Selection pane, select the folder containing your application's .project file and click Next, as shown in Figure 8.27.
Figure 8.27 Projects Selection in the Import Wizard
If you want to import multiple Eclipse projects, you can select multiple folders in the tree view using Ctrl+left-click on each folder, or you can select a range of folders by left-clicking on the first folder and then using Shift+left-click on the last folder.
When the Confirmation pane is displayed, review the list of Eclipse projects that have been selected for import. When you are satisfied with the list, click Finish, as shown in Figure 8.28.
Figure 8.28 Confirmation pane in the Import Wizard
Team Explorer Everywhere will download the project's source code into your Eclipse workspace and load the Eclipse Project into Package Explorer, as shown in Figure 8.29. You are now ready to work with your application code.
Figure 8.29 Eclipse project open in Package Explorer
Add, Delete, Edit, Rename, Check-Out, and Check-In Files
Team Explorer Everywhere provides much of the same functionality to Eclipse developers as Team Explorer provides to Visual Studio developers. The features, commands, and even the look and feel are almost identical. Because of this, the information contained in Chapter 6 relating to check-out, check-in, adding, deleting, and renaming files in version control is also applicable to Eclipse developers.
Because of the similarity between Team Explorer Everywhere and Team Explorer, much of the documentation available to Team Explorer users is also applicable to Team Explorer Everywhere users. For more information on using Team Explorer Everywhere, see Adopting Team Explorer Everywhere on MSDN at http://aka.ms/AdoptingTEE.
Eclipse developers working with a Git-based team project can use the EGit plug-in to access their team project repository just like any other Git repository. EGit is maintained on the Eclipse website and can be found in the Eclipse Marketplace or athttp://www.eclipse.org/egit. When working with Git-based team projects stored on Visual Studio Online, you need to enable Alternate Credentials on your account so that basic authentication can be used to connect to the Service. For information on enabling Alternate Credentials in Visual Studio Online see http://aka.ms/VSOAlternateCredentials.
Working with the Cross-Platform Command-Line Client
Team members whose development machines are running an operating system that doesn't provide a GUI in which to run Eclipse and Team Explorer Everywhere can still participate in your team project. For those team members, Microsoft provides the Team Explorer Everywhere Command-Line Client (CLC), which can be used to access the team project's version control repository from a command shell.
Install and Connect
The first step is to download the Command-Line Client files from Microsoft. The Command-Line Client is part of Team Explorer Everywhere and can be downloaded from the Team Explorer Everywhere download page at http://aka.ms/DownloadTEE. When you click the Download button you will be given the option to select the files to be downloaded. Select the TEE-CLC-12.0.0.zip file's check box and click Next, as shown in Figure 8.30.
Figure 8.30 Team Explorer Everywhere download page
Once the zip file is downloaded, copy the archive over to the target machine and extract the files from the archive. Now you will need to change the system/shell's PATH environment variable to include the folder where the archive was unzipped. You will also need to add the Java Runtime Environment or Java Development Kit location to the PATH or set the JAVA_HOME environment variable to point to your Java installation.
Once that is complete, open a command prompt and type tf and hit Enter. You should see output from the Command-Line Client, as shown in Figure 8.31.
Figure 8.31 Command-Line Client help
For additional information about any of the tf commands, type tf help followed by the name of the command you want information about. So to see how the merge command works, type tf help merge.
Every interaction with Team Foundation Server is constrained by your rights within TFS. When you perform a version control operation, TFS needs to be able to authenticate you prior to performing the operation.
When using the tf command-line tool you must provide your credentials by adding the -login:<username>,<password> option to the tf command. For example, if you want to perform a check-in, you would use tf checkin -login:tfs2013\steve,myPassword. The user name can be specified in domain\username or username@domain format.
If you want to let Team Explorer Everywhere cache your credentials, you can set the TF_AUTO_SAVE_CREDENTIALS environment variable to any value. When this value is set, the next usage of the -login option will save the credentials to the credential cache. From that point on, those credentials will be used for each invocation of the tf command.
For more information see http://aka.ms/CLCAuth.
Creating a Workspace Mapping
Before you can perform any version control operations, you need to review and accept the Microsoft Software License Terms. To view the License, type tf eula and press Enter. When the License is displayed, it will prompt you for acceptance. Type y or yes and press Enter. If you want to accept the License without these steps, you can type tf eula /accept.
Now that the legal stuff is out of the way, you will need to create a workspace on your machine that connects it to Team Foundation Version Control in your team project. In the first command in Figure 8.32, we are creating a workspace called MyApp inside thehttp://tfs2013:8080/tfs/DefaultCollection team project collection.
Figure 8.32 Mapping a server folder to a local folder
Next you need to create a folder mapping from a location in version control to your local machine. You'll start by creating a local folder called MyApp in C:\, and then you'll use the tf workfold command to map the folder in version control to your local folder, as shown in Figure 8.32.
Performing a Get from Team Foundation Server
To perform version control activities, you need to change you working folder to the local directory that Team Foundation Server knows about so you type cd c:\MyApp and press Enter. Once there, you can use the tf get command to retrieve the latest version of all of the files in your project from source control, as shown in Figure 8.33.
Figure 8.33 Retrieving the latest version from version control
Editing Files and Committing Changes
Now with that done, you can make changes to your files. When you're ready to check in your changes, you can issue a tf status command to see what is changed in my workspace. Figure 8.34 shows that you have made an edit to the HelloWorld.java file. To commit that change to version control you'll use the tf checkin command with the /comment parameter to add a comment to your check-in, as shown in Figure 8.34.
Figure 8.34 Reviewing and committing changes
To show that these changes were actually committed to Team Foundation Server, you can open Eclipse, go to your project folder in Source Control Explorer, and get the history of changes to that folder. As you can see in Figure 8.35, Changeset 55 contains the comment that you added when you checked in your edits.
Figure 8.35 Viewing the changeset in Eclipse
For more information on using the Team Explorer Everywhere Command-Line Client, see http://aka.ms/CLCBeginnersGuide. For help with the available commands, see the Team Explorer Everywhere Command-Line Reference on MSDN athttp://aka.ms/CLCCommands.
In this chapter, you learned what constitutes a heterogeneous team and how Team Foundation Server supports those teams across disparate operating system and development platforms. You were shown how Xcode developers can use Team Foundation Version Control and Git-based team projects to safeguard their source code.
Additionally, you were introduced to Team Explorer Everywhere both as a plug-in to the Eclipse IDE as well as in a command-line client for use in situations where development occurs in a non-GUI-based environment.
In Chapter 9, you learn how you can migrate your source code from legacy version control systems into Team Foundation Server.