In 2021, using azure devOps Tfs Client Api
As per the documentation, the Api is meant for following Tfs servers.
Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018 - TFS 2013
Namespaces used here:
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.VisualStudio.Services.Client;
using Microsoft.VisualStudio.Services.WebApi;
Create VssConnection as follows,
string myTfsProjectUri = "url path to your tfs project";
VssConnection myConnection = new VssConnection( new Uri( collectionUri ), new VssClientCredentials() );
Create TfvcHttpClient client as follows,
TfvcHttpClient myVersionControlHttpClient = myConnection.GetClient<TfvcHttpClient>();
Get Changesets using search criteria as follows (given snippet finds all the check-ins between given fromCheckInId & toCheckInId),
List<TfvcChangesetRef> changeSets = VersionControlHttpClient
.GetChangesetsAsync(
projectName, /* Tfs Project name */
null, /* Max Comment length, can be null */
null, /* Number of results to Skip, can be null */
null, /* Maximum Number of results to return, can be null */
null, /* Results are sorted by ID in descending order by default. Use id asc to sort by ID in ascending order */
new TfvcChangesetSearchCriteria()
{
ItemPath = branchName, /* Path to Branch under given project */
FromId = fromCheckinId, /* From check-in id to start search */
ToId = toCheckinId /* To check-in id to end search */
} ).Result;
This API can be used with FromDate and ToDate search criteria as well.
For more information, read official documentation