Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Team Foundation Server 2015 Cookbook

You're reading from   Microsoft Team Foundation Server 2015 Cookbook Over 80 hands-on DevOps and ALM-focused recipes for Scrum Teams to enable the Continuous Delivery of high-quality Software... Faster!

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher
ISBN-13 9781784391058
Length 340 pages
Edition 1st Edition
Arrow right icon
Authors (2):
Arrow left icon
Tarun Arora Tarun Arora
Author Profile Icon Tarun Arora
Tarun Arora
Tarun Arora Tarun Arora
Author Profile Icon Tarun Arora
Tarun Arora
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Team Project Setup FREE CHAPTER 2. Setting Up and Managing Code Repositories 3. Planning and Tracking Work 4. Building Your Application 5. Testing Your Application 6. Releasing Your Application 7. Managing Team Foundation Server 8. Extending and Customizing Team Foundation Server 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:

Getting ready

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.

Getting ready

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:
    How to do it...
  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
    
You have been reading a chapter from
Microsoft Team Foundation Server 2015 Cookbook
Published in: Jan 2016
Publisher:
ISBN-13: 9781784391058
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime