Skip to content

Instantly share code, notes, and snippets.

@house9
Created August 19, 2010 19:18
Show Gist options
  • Save house9/538657 to your computer and use it in GitHub Desktop.
Save house9/538657 to your computer and use it in GitHub Desktop.
public static void ScriptMain(Project project)
{
project.Log(Level.Info, "Connect to " + project.Properties["tfs.server"]);
TeamFoundationServer tfs = new TeamFoundationServer(project.Properties["tfs.server"]);
// Get a reference to Version Control.
Type type = typeof(VersionControlServer);
VersionControlServer versionControl = (VersionControlServer)tfs.GetService(type);
project.Log(Level.Info, "get changesetId for " + project.Properties["tfs.fullpath"]);
IEnumerable changeSets = versionControl.QueryHistory(project.Properties["tfs.fullpath"], VersionSpec.Latest, 0, RecursionType.Full, null, null, null, 1, true, false);
int latestChangesetId = 0;
// there is only one
foreach(Changeset c in changeSets)
{
latestChangesetId = c.ChangesetId;
}
project.Log(Level.Info, "ChangesetId is " + latestChangesetId.ToString());
project.Properties["project.version.revision"] = latestChangesetId.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment