Book Image

Microsoft Team Foundation Server 2015 Cookbook

By : Tarun Arora
Book Image

Microsoft Team Foundation Server 2015 Cookbook

By: Tarun Arora

Overview of this book

Team Foundation Server (TFS) allows you to manage code repositories, build processes, test infrastructure, and deploy labs. TFS supports your team, enabling you to connect, collaborate, and deliver on time. Microsoft's approach to Application Lifecycle Management (ALM) provides a flexible and agile environment that adapts to the needs of your team, removes barriers between roles, and streamlines processes. The book introduces you to creating and setting up team projects for scrum teams. You'll explore various source control repositories, branching, and merging activities, along with a demonstration of how to embed quality into every code check-in. Then, you'll discover agile project planning and management tools. Later, emphasis is given to the testing and release management features of TFS which facilitate the automation of the release pipeline in order to create potentially shippable increments. By the end of the book, you'll have learned to extend and customize TFS plugins to incorporate them into other platforms and enable teams to manage the software lifecycle effectively.
Table of Contents (16 chapters)
Microsoft Team Foundation Server 2015 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a new Team Project through the command line


As a Team Foundation Server administrator, you'll find yourself creating Team Projects over and over again. Team Project creation process can be scripted thanks to Team Foundation Server Power Tools. A Team Project is a container that can host multiple Teams and simplifies sharing of various artifacts such as processes, master backlogs, build definitions, and code artifacts. More often than not, you'll find that a new Team Project has been requested in ignorance simply because the requestor doesn't fully understand how multiple Teams can be accommodated in a Team Project. It is always beneficial to have a conversation to fully understand why a new Team Project has been requested. In this recipe, you'll learn how to script the creation of a new Team Project using the command line.

Getting ready

Microsoft Visual Studio Team Foundation Server Power Tools are available through the Visual Studio Gallery. Power Tools are a set of tools, enhancements, and command-line utilities that can make a TFS administrator more productive. Download and install the Power Tools by browsing to http://bit.ly/1jJkEmt:

Download the Microsoft Visual Studio Team Foundation Server 2015 Power Tools from the Visual Studio Extensions Gallery

Installing TFS Power Tools installs the command-line utility Tfpt.exe. Tfpt.exe is a companion tool to tf.exe that offers additional version control commands, Work Item tracking, and Team Project manipulation. Open up a new command line and type tfpt.exe /?. If you do not see a list of available commands as shown in the following screenshot, the Power Tools haven't been installed correctly. Verify the installation before proceeding.

How to do it...

  1. Create a new folder TFSCookbook\Chapter01 in the C:\ drive. Copy the text as follows in Notepad and save it to C:\TFSCookbook\Chapter01 as settings.xml:

    <?xml version="1.0" encoding="utf-8"?> 
    <Project xmlns="ProjectCreationSettingsFileSchema.xsd">
       <TFSName>http://tfs2015:8080/tfs</TFSName>
    <LogFolder>C:\TFSCookbook\Chapter01</LogFolder>
        <ProjectName>ScriptedTeamProject01</ProjectName> 
        <ProjectReportsEnabled>true</ProjectReportsEnabled>
        <ProjectSiteEnabled>true</ProjectSiteEnabled>
        <ProjectSiteTitle>ScriptedTeamProject01</ProjectSiteTitle>
        <SccCreateType>New</SccCreateType> 
        <ProcessTemplateName>Scrum</ProcessTemplateName> 
    </Project>
  2. In command prompt run the following command:

    tfpt createteamproject /settingsfile:"C:\TFSCookbook\Chapter01\settings.xml" /validate /verbose
    
  3. You should receive a message confirming whether the validation is successful. If not, check the error message against the information in the settings file:

  4. To create the Team Project, run the earlier command by removing the /validate switch.

    tfpt createteamproject /settingsfile:"C:\TfsCookbook\Chapter01\settings.xml" /verbose
    
  5. Wait for the Team Project creation process to complete.

    Note

    Note that tfpt createteamproject does not support scripting a new Team Project with Git as the source control repository.

How it works...

The Team Project creation command takes the settings.xml file as an input; let's review the information that was provided in settings.xml:

  • TFSName: This tag is used to specify the connection details of the TFS Server where you want the new Team Project to be created.

  • LogFolder: This tag is used to specify the folder directory for the log file. This path should exist on the TFS application tier.

  • ProjectName: The Team Project name. If you specify a Team Project name that already exists, the Team Project creation process will fail during the validation process.

  • ProjectReportsEnabled: Certain default project reports are created as part of the Team Project creation process. This tags accepts a Boolean value; pass false to skip the default reports from being added.

  • ProjectSiteEnabled: If your Team Foundation Server installation has SharePoint services enabled, you can pass a value of true in this tag to have a SharePoint Team site created for the new Team Project.

  • ProjectSiteTitle: This tag is ignored if the value of ProjectSiteEnabled is false. This tag is used to specify the name of the SharePoint Team site you have chosen to create as part of the Team Project creation process.

  • SccCreateType: If a true value is passed in this tag, a new TFVC source control is created, alternatively an existing TFS source control path can be passed to create a TFVC source control from the contents of the specified TFS path.

  • ProcessTemplateName: This tag is used to pass the name of the Process Template that the Team Project should be based on.

    Note

    A list of all Process Templates available on your Team Foundation Server can be seen from Process Template Manager. To access Process Template Manager, open Visual Studio and connect to Team Foundation Server. From Team Explorer choose Settings. From the Settings view, click on Process Template Manager.

Now, let's review the createteamproject command:

tfpt createteamproject /settingsfile:"C:\TFSCookbook\Chapter01\settings.xml" /validate /verbose

The /settingsfile path is used to specify the location of the settings file. TFPT parses the settings file and triggers the Team Project creation process by connecting to the Team Foundation Server using the details specified in the settings file. The Team Project isn't created when the /validate switch is used; the whole process is run as a validation to identify any potential issues. The /verbose flag is used to log details of the operations being performed during this process. The verbose option can be very useful when troubleshooting issues.

There's more...

The tfpt.exe command-line tools also provide many other useful commands. The two worth mentioning are addprojectportal and addprojectreports.

  • addprojectportal: Over time, one may recognize the need for creating or moving the project portal. This command supports both operations in an existing Team Project.

    tfpt addprojectreports /collection:http://tfs2015:8080/tfs /teamproject:"Fabrikam" /processtemplate:"Scrum" /webapplication:"" /relativepath:"pathfromwebapp" /validate /verbose
    
  • addprojectreports: The add reports operation creates the reports in the chosen Team Project. This command overwrites the reports if they already exist.

    tfpt addprojectreports /collection:"http://tfs2015:8080/tfs" /
    teamproject:"Fabrikam" /processtemplate:"Scrum" /validate /verbose