My purpose is to get the latest changeset during TFS build and then use this changeset num to update assembly version.
In TFS 2012, i use BuildDetail.BuildDefinition.Workspace.Mappings to get workspace mappings then use the method below to get latest changeset:
private string GetLatestChangesetNum(Workspace workspace, List<IWorkspaceMapping> workspaceMappings)
{
var changesets =
workspace.VersionControlServer.QueryHistory(workspaceMappings[0].ServerItem, VersionSpec.Latest, 0,
RecursionType.Full, null, null, null, 1, true, false).Cast<Changeset>();
return changesets.First().ChangesetId.ToString();
}
The problem is when i migrate to TFS build 2013, i found BuildDetail is not existed. So any other API could help this?