How to get files associated with a changeset?
This information is very useful when deploying or installing a new build generated by TFS Build Server. It can give information for testers to target specific areas of the application. TFS Source Control service can provider the necessary information. The following code should retrieve all the files associated with specific changeset id.
private static List<string> GetFilesAssociatedWithBuild(TfsTeamProjectCollection teamProjectCollection, int changesetId)
{
List<string> files = new List<string>();
VersionControlServer versionControlServer = teamProjectCollection.GetService(typeof(VersionControlServer)) as VersionControlServer;
Changeset changeset = versionControlServer.GetChangeset(changesetId);
if (changeset.Changes != null)
{
foreach (var changedItem in changeset.Changes)
{
string item = changedItem.Item.ServerItem;
if (!files.Contains(item))
{
files.Add(item);
}
}
}
return files;
}
However, you would need the changeset ID associated with the build for this to work. In my next post, I will talk about how to get changeset ID’s for a given build URI.
Thanks
RV