In this post I will show you how to modify that code to modify that task to use the changeset number as the build number (which is virtually incremental in a CI environment).
Simply reference the Team Foundation Server Assemblies required for the following using statements:
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
And now simply use this little method to get the changeset number:
private int GetLatestChangeSetId()
{
// Get a reference to our Team Foundation Server.
string tfsName = @"http://myserver:8080";
TeamFoundationServer tfs = new TeamFoundationServer(tfsName);
// Get a reference to Version Control.
VersionControlServer versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
int latestChangesetId = versionControl.GetLatestChangesetId();
return latestChangesetId;
}
No comments:
Post a Comment