Connecting Team City to Visual Studio Online using Git source control
I was on a client project that was using Team City for their builds. I migrated their source control from SVN to using Visual Studio Online (as they had less than 5 users it was free). But I had issues trying to find any documentation on how to successfully connect Team City to Visual Studio when you are using Git for the source control. Hopefully these steps will help someone else in the future.
Where I was going wrong was trying to treat it like it was a TFS project, instead I should have been treating it like a standard Git repository.
For this blog post I am using the TFS team project I created during a live demo I gave for the Windows Azure web camp.
Step 1: Enable alternate authentication credentials
You will need to tell Visual Studio Online to enable other tools (such as command line Git tools & Team City) to be able to log in using a username & password.
- Load your team portal, then in the top right click “My Profile”.
- Go to the credentials tab and click “Enable alternate credentials”
Step 2: Obtain the URL for your Git repository
The easiest way I’ve found to get the URL for your git repository is to open a Git command prompt and list the remote origin
- In Visual Studio go to the changes section in the Team Explorer tab.
- Click “Actions” and select “Open Command Prompt”
- In the command prompt type
git remote show origin
Step 3: Enter details into Team City
This is the part that confused me, as I kept trying to connect with the TFS plugin. The secret is to just treat it as a Git repository.
- In your team city project, click to add a “New VCS Root”
- Type of VCS: Leave as <guess from repository URL>
- Repository URL: Enter the Git repository URL obtained from the command prompt (in this example it would have been https://ausazurewebcamp.visualstudio.com/defaultcollection/_git/MelbourneSoftdrink
- Username: Enter your Visual Studio Online username
- Password: Enter the password you created when enabling Alternate Credentials.
Once it has connected you should be able to just click “Auto-Detect build steps” and have Team City download your source code, and automatically find your .sln file.