yo TFS

NOTE:  This has been replaced by yo Team.

After releasing yo VSTS I started getting requests for a port to support Team Foundation Server.  Although the REST APIs are similar they are at different versions and some capabilities of Team Services have not made it to Team Foundation Server yet. Therefore, this requires a completely different generator.

yo TFS allows you to create complete DevOps pipelines by simply answering a few questions.  You no longer have to visit the web interface to configure TFS.

To use yo TFS you must have the following:

  • Team Foundation Server 2017 with the following extensions
    • Docker
  • Configured build agent with the following capabilities
    • Maven
    • Bower
    • Node.js
    • NPM
    • .NET Core SDK
    • Azure PowerShell
    • Docker Toolbox
    • .NET Framework 3.5
    • Git
  • Team Foundation Server Personal Access Token
  • Azure Subscription
  • Node.js
  • NPM
  • Yeoman
  • Git

The goal of yo TFS and yo VSTS is to automate the automation. I have noticed many struggle to configure everything correctly to build a complete DevOps pipeline.  Using yo TFS/VSTS you no longer have too.  The entire pipeline will be created for you in just a few minutes.  Then all your team has to do is commit changes and watch them flow into Azure App Service or a Docker container.

After installing Yeoman with NPM:

npm install –g yo

You can use the yo command to install the TFS Generator.  Simply type yo and use the menu to install a generator and search for TFS.  After the generator is installed you can select it from the menu to create your first pipeline.

While I was porting from VSTS to TFS I took this opportunity to improve on my original design.  I like the changes so much I intend to incorporate them into the next release of yo VSTS as well.  One of the first changes I made was to break the solution down into smaller sub generators. In the original design there were only 4 sub generators.  One for each language Java, Node.js and .NET Core and one for all of VSTS which included code for creating the Project, Git, Azure Service Endpoints, Docker Service Endpoints, Build and Release.  This required you to rerun the entire generator even if all you wanted was a build. So this time around each of those areas is a separate sub generator that can be run individually.  This increased the total number of sub generators from four to eleven.  The main generator is TFS with the following sub generators:

  • asp - scaffolds a .NET Core application using Razor and Bootstrap
  • azure - creates an Azure Service Endpoint
  • build - creates a CI build
  • docker - creates a Docker Service Endpoint
  • git - clones the Git repo and adds & commits the initial files
  • java - scaffolds a Java application using Tiles and Bootstrap
  • node - scaffolds a Node.js application using Pug and Bootstrap
  • pipeline - creates a CI build and CD release
  • project - creates the team project
  • registry - creates Docker Registry Service Endpoint
  • release - creates a release

To use the main generator simply enter

yo tfs

If you want to use any of the sub generators individually simply add a : and the name of the desired sub generator.  For example to create a project type

yo tfs:project 

Each generator will prompt you for the required information for that sub generator.

yo tfs
? What is your TFS URL including collection
  i.e. http://tfs:8080/tfs/DefaultCollection? http://localhost:8080/tfs/DefaultCollection
? What is your TFS Access Token? ****************************************************
? What is the name of your application? Demo

However, you can also pass all the information on the command line and by pass the prompts all together.

yo tfs:project DemoProject http://localhost:8080/tfs/DefaultCollection <Personal Access Token>

You do not have to provide all the arguments on the command line.  Any you omit you will be prompted for.

yo tfs:project DemoProject http://localhost:8080/tfs/DefaultCollection
? What is your TFS Access Token?

Below is a table of each generator with the order list of arguments.

Generator

Arguments

tfs type - asp, node or java
applicationName - Will be the folder created on disk and the Team Project name
tfs - TFS URL including collection
azureSub - Azure Subscription Name
azureSubId - Azure Subscription ID
tenantId - Azure Tenant ID
servicePrincipalId - Azure Service Principal ID
queue - TFS Agent queue to use
target - paas or docker
installDep - true or false
groupId - Java application Group ID
dockerHost - Docker Host URL
dockerCertPath - Path to Docker Host certs
dockerRegistryId - Docker Hub Username
dockerRegistryEmail - Docker Hub Email
dockerPorts - Port mapping for container
dockerRegistryPassword - Docker Hub password
servicePrincipalKey - Azure Service Principal Key
pat - TFS Personal Access Token
asp applicationName
installDep
azure applicationName
tfs
azureSub
azureSubId
tenantId
servicePrincipalId
servicePrincipalKey
pat
build type
applicationName
tfs
queue
target
dockerHost
dockerRegistryId
pat
docker applicationName
tfs
dockerHost
dockerCertPath
dockerRegistryId
dockerRegistryEmail
dockerPorts
dockerRegistryPassword
pat
git applicationName
tfs
action - clone or commit
pat
java applicationName
groupId
installDep
node applicationName
installDep
pipeline type
applicationName
tfs
queue
target
azureSub
azureSubId
tenantId
servicePrincipalId
dockerHost
dockerCertPath
dockerRegistryId
dockerRegistryEmail
dockerPorts
dockerRegistryPassword
servicePrincipalKey
pat
project applicationName
tfs
pat
registry applicationName
tfs
dockerRegistryId
dockerRegistryEmail
dockerRegistryPassword
pat
release type
applicationName
tfs
queue
target
azureSub
dockerHost
dockerRegistryId
dockerPorts
pat

Enter “” for any unused arguments.  For example is you are targeting Docker you will not have values for the Azure arguments. Simply put “” in there place. For example this is how you would add a Docker pipeline to an existing project.

yo tfs:pipeline node nodeDemo http://localhost:8080/tfs/DefaultCollection Default docker "" "" "" "" tcp://dockerhost:2376 D:\.docker\dockerhost DockerHUBUser DockerEmail 3000:3000 DockerPassoword PAT

To target Azure App Service you are going to need a Service Principal which you can learn how to create in my previous blog post.  If you want to target Docker you will need a Docker Host.  You can read how to create one here.

Just like yo VSTS, yo TFS is open source. If you would like to contribute you can read the requirements on the GitHub wiki and use this post to build a TFS server to develop on.

I look forward to the pull requests to help add new languages and features to both yo TFS and yo VSTS.

Pingbacks and trackbacks (2)+

Add comment

Loading