Features How-To's Tips & Tricks

TeamCity and Visual Studio Online Source Control

Many teams are working with Visual Studio Online (VSO), a hosted Team Foundation Server that provides source control and issue tracking as a cloud service. While VSO comes with a build server as well, lots of developers prefer to use TeamCity for their continuous integration story because of its advanced features to automatically run builds for feature branches,  automatic merge and many others.

TeamCity supports building projects that are hosted on Visual Studio Online, the only thing we have to do is add a VCS root to our build configurations. Depending on the version control system used for the project (Git or Team Foundation Version Control – TFVC), this will be slightly different. Let’s have a look at our options.

Enabling alternate credentials

Independent from the version control system used, we will have to enable alternate credentials support on our Visual Studio Online account. Applications that work outside the browser, such as the git client or the command-line TFS client, require basic authentication credentials to work. By editing our VSO profile, we can set a secondary username that can be used for these scenarios.

After navigating to our VSO account portal, we can use the menu at the top-right to edit our profile. The Credentials tab lets us enable alternate credentials. After clicking Enable alternate credentials, we can set a secondary username and password we can use later on.

Visual Studio alternate credentials for TeamCity

After saving our changes here, we can proceed with connecting TeamCity to Visual Studio Online version control.

Connecting to Visual Studio Online Git

For teams embracing Git source control with Visual Studio Online, TeamCity setup is really easy. From the Administration section, we can create a new project from URL. Next, we can enter the URL to our VSO Git repository and provide the alternate credentials we’ve just set up. TeamCity will auto-detect we’re using a Git repository.

Create project from URL

Connecting to Visual Studio Online TFVC

Projects that are using Team Foundation Version Control (TFVC) can leverage TeamCity in their projects, too. The workflow to get started with a new project is the same: from the Administration section we can create a new project from URL, entering the URL to our Visual Studio Online project’s TFS path. This typically looks like https://accountname.visualstudio.com/DefaultCollection/$/ProjectName. For credentials, we can enter our Microsoft Account credentials, or use the alternate credentials created earlier.

Create TeamCity Project from Visual Studio Online

Note that the name in the Microsoft Account or alternate credentials has to be prefixed with ##LIVE##\. When creating projects/VCS roots from URL in TeamCity 8.1.5+, the prefix is not required.

Creating the Build Configuration

Once we have connected to Visual Studio Online, TeamCity will try to identify potential build steps we can use. It will browse our repository and look for Visual Studio solution files, projects, batch files, NuGet packages that have to be restored and so on. We can use these automatic steps, or add our own to fine-tune our build process.

Auto-detectedbuild steps

When at least one build step is configured, we can start our build. It is possible to fine-tune our version control integration from the build configuration’s Version Control Settings. In here, we can configure what our branch structure looks like so that TeamCity automatically runs the build configuration for any feature branch we have. We can also modify the VCS Changes Checking interval and change when to check VSO  for changes.

Using a Trigger, a build can automatically be started when chenges are checked in to VSO. The VCS Trigger must be added to the build configuration to do this. Optionally, we can build for every single change, accumulate check-ins and so on.

Automatically start TeamCity build when changes checked in to Visual Studio Online

Many other triggers are available, such as the Schedule Trigger which starts a build at a given time. The Finish Build Trigger can start a build once another build has been finished. We can also monitor NuGet feeds and trigger a build when a given dependency changes.

TeamCity is a great companion to Visual Studio Online for many scenarios. Happy building!


Comments below can no longer be edited.

12 Responses to TeamCity and Visual Studio Online Source Control

  1. Avatar

    Jacob G. Rillema says:

    October 23, 2014

    Thanks for the post. A couple questions with this integration. Will the build results, test results and any artifacts get pushed back to VSO or will they only reside in the Team City build server? Also how would we update our markdown in VSO to indicate build was successful, failed, etc?

  2. Avatar

    Maarten Balliauw says:

    October 27, 2014

    @Jacob – The build and test results will remain in TeamCity. You may want to have a look at http://jake.ginnivan.net/teamcity-build-results-in-tfs/ (I haven’t tested it but it looks promising).

    With regards to updating Markdown, you could use the VSO API for this. Do keep an eye on our blog as we’re doing some work around notifications from TeamCity to VSO.

  3. Avatar

    Bernard says:

    November 25, 2014

    We are having some issues regarding the connection to VisualStudio Online.

    Alternate credentials are enabled for the user account used and the URL entered is:

    Could not create a project by specified URL, URL is not recognized

    I have tried numerous of combinations, but can’t figure out how the URL should be. When browsing it all I get is a 404, is there something basic we are missing?

    • Avatar

      Pavel Sher says:

      December 1, 2014

      What version of TeamCity do you use?

      • Avatar

        Pauli says:

        December 19, 2014

        I have same problem. I have TeamCity 9.0.

        • Avatar

          Max says:

          January 8, 2015

          Try removing “/$/xxx/” from your URL and add it as it suggests under the TFS Settings URL input box.

          I have just “https://xxx.visualstudio.com/DefaultCollection” and it works.

        • Avatar

          Pavel Sher says:

          January 8, 2015

          I just checked it myself, and it works fine. If you still have these problems please contact us via teamcity-feedback@jetbrains.com.

          • Avatar

            Andrew says:

            January 13, 2015

            Same problem for me, but only for TFS based. Git works. TC Version 9.0.1 (build 32116)

            TFS Project: The following result in “Cannot create a project using the specified URL. The URL is not recognized.”



            But for a git project added the same way it works.


          • Avatar

            Andrew says:

            January 14, 2015

            So it appears that using projects with spaces that would give the URL %20 will break for TFS projects and will add implicit parameters to the git projects.

  4. Avatar

    Matt K says:

    January 13, 2015

    We are having this same problem when trying to connect to VSO. Our error is:

    Cannot create a project using the specified URL. The URL is not recognized.

    Any ideas?

    • Avatar

      Pavel Sher says:

      January 28, 2015


      Please try it in 9.0.2 which should be released really soon.

Discover more