We are going to learn how to connect Team Foundation Server/Visual Studio Online using a .Net Console Application in this article.
Create a project
Open Visual Studio
On the start window, choose Create a new project.
On the Create a new project window, enter or type console in the search box. Next, choose Console App (.NET Framework) Visual C# from the list, and then click Ok.
Install and use a package
NuGet packages contain reusable code that other developers make available to you for use in your projects.
In Solution Explorer, right-click References and choose Manage NuGet Packages.
Choose “nuget.org” as the Package source, select the Browse tab, search for Microsoft.TeamFoundationServer.Client, select that package in the list, and select Install
Select the Browse tab, search for Microsoft.TeamFoundationServer.ExtendedClient, select that package in the list, and select Install:
Add code
Make sure to include the following headers in your Program.cs file
Microsoft.TeamFoundation.Client
Microsoft.TeamFoundation.SourceControl.WebApi
System
System.Collections.Generic
System.IO
System.Linq
System.Net
System.Xml.Linq
Add the following code to connect your console application code with TFS and make sure you are able to generate the client context.
Add the following code to get all the files within the given project path
Add the following code to get the file content for the given file path
Add the following code to get the changesets applied on the given file path
Add the following code to filter the changesets applied by a specific code author
Add the following code to get the file content of a specific file version based on changeset ID
Hope you found this article helpful! Let me know if I might have missed anything or can be done better.
Subscribe
Get the latest and greatest from me delivered straight to your inbox.