Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to map a TFS item url to something viewable

Tags:

tfs

tfs-sdk

We are programmatically generating deployment emails, based on the history of changesets and associated workitems since the last deployed build. They look a bit like the build summary info inside Visual Studio (but with many builds combined).

There appear to be useful URLs in the data (like vstfs:///VersionControl/Changeset/205151), but being new to the TFS SDK I do not if/how this maps to a viewable item (e.g. http://tfsserver:port/somepath/...). The build summary links inside Visual Studio are clickable, but are they VS-only links?

If possible we want to include links in the email that open the related item (in a browser?), so I guess I need to know if TFS paths are web-browsable and if so, how?

Suggestions welcomed. Thanks.

like image 960
Gone Coding Avatar asked Jun 24 '11 10:06

Gone Coding


3 Answers

This is the uRl i have been using to access work items,

=> http://ServerName:PortNumber/tfs/web/wi.aspx?id=xxidxx

Edit The format i have specified does work with TFS 2010. It basically generates the path to the work item in Web view. Clicking on this opens the work item in the web view.

As an alternate, you could get a navigatable URL programmatically as well.

var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("TFSURL"));
var versionControl = tfs.GetService<ICommonStructureService>();

var projects = versionControl.ListAllProjects();

var myService = tfs.GetService<TswaClientHyperlinkService>();

var myUrl = myService.GetChangesetDetailsUrl(21);

So, the service "TswaClientHyperlinkService" is microsofts TFS hyperlink service. This will generate the url formats for Absolute path, relative path, Path and Query, blah blah.

HTH,

Cheers, Tarun

PS - I hate to be wrong!!! hahaha... enter image description here

EDIT And since in your case you have the URI available and you already are using the TFS API, these two lines of code would do the trick.

var testManagementService = tfs.GetService<ILinking>();
var testControllers = testManagementService.GetArtifactUrl(@"vstfs:///VersionControl/Changeset/205151");

This will generate, https://ServerName:PortNumber/defaultcollection/VersionControl/Changeset.aspx?artifactMoniker=205151

HTH,

Cheers, Tarun

like image 182
Tarun Arora Avatar answered Nov 23 '22 17:11

Tarun Arora


The following seems to be the standard url for accessing work items

http://TFS_Name:port_number/WorkItemTracking/Workitem.aspx?artifactMoniker=work_Item_Id

like image 31
Daniel Powell Avatar answered Nov 23 '22 18:11

Daniel Powell


The vstfs links are called "artifact IDs" and are internal data to TFS that is expected to only be consumed by a TFS client. A TFS client will parse that data and determine how to display that data. For a changeset link like you provide, the rich clients will open up a dialog with the changeset details. A web client would translate that link into a URI. And the various TFS libraries are able to provide you more data on this artifact using that ID.

If you wanted to create your own link to TFS Web Access, the strictly proper way to do this is to query some information on the server. Once you have a TswaClientHyperlinkService, you can query for the Web Access URIs for various services, such as view a changeset or view a work item. Some examples are shown on Martin Woodward's blog.

like image 44
Edward Thomson Avatar answered Nov 23 '22 19:11

Edward Thomson