Josh
Josh

Reputation: 3

How to return the version (changeset) of a file in a workspace using the TFS object model?

How can the version (changeset) of a file in a workspace be returned using the TFS object model? I want to be able to pass in the path of a file in my workspace and have the changeset returned.

Upvotes: 0

Views: 292

Answers (1)

Jim Lamb
Jim Lamb

Reputation: 25805

Here's the general approach:

var versionControl = projectCollection.GetService<VersionControlServer>();

var item =
    versionControl.GetItem(
        "$/TeamProject/Main/Solution/Program.cs",
        new WorkspaceVersionSpec("workspace", "user"));

int changesetId = item.ChangesetId;

The key is the WorkspaceVersionSpec object.

Upvotes: 1

Related Questions