Reputation: 1769
For a particular branch I'd like to generate a list of file names and the date that they were originally added to TFS. I don't really mind what method I use to get it, but command line or C# solutions would be great. I haven't included anything that I've tried because I don't really know where to start!
I'm trying to get a result something like this:
Date added File name
========================
10/02/2015 File1.txt
16/05/2015 File2.txt
19/08/2014 File3.txt
Upvotes: 1
Views: 1349
Reputation: 52798
OK, this can be done, but I don't know how well this will perform, it probably depends on the size of you code base.
Using the VersionControlServer
on the TFS API I'm getting all the items and then for each item querying the history to get the first changeset and then getting the details:
void Main()
{
const String CollectionAddress = "http://tfs:8080/tfs/DefaultCollection";
using (var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(CollectionAddress)))
{
tfs.EnsureAuthenticated();
var server = tfs.GetService<VersionControlServer>();
server.GetItems(
path: "$/Code/",
version: VersionSpec.Latest,
recursion: RecursionType.Full,
deletedState: DeletedState.NonDeleted,
itemType: ItemType.File)
.Items
.Select(
item =>
server
.GetBranchHistory(
itemSpecs: new[] { new ItemSpec(item.ServerItem, RecursionType.None), },
version: VersionSpec.Latest)
.Single()
.Select(
a =>
new
{
a.Relative.BranchToItem.ChangesetId,
a.Relative.BranchToItem.CheckinDate,
a.Relative.BranchToItem.ServerItem,
})
.Single())
.Dump(5);
}
}
You can download a working Linqpad Script from here - targeting VS2013 object model.
Upvotes: 3
Reputation: 77906
From MSDN TFS History command it seems you can run the below command from Visual Studio command prompt which will get you the change set files for a particular day
tf history "local path" /version:D2015-09-03 /recursive /noprompt
Upvotes: 0