Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open the TFS changeset details dialog view using a Visual Studio add-in?

I have a specific artifact in TFS, say changeset "123", which has the URI "vstfs:///VersionControl/Changeset/123". I realized that the link "http://tfs:8080/tfs/web/UI/Pages/Scc/ViewChangeset.aspx?changeset=123" will open the changeset detail view using the web-browser.

What I would like to do is open the changeset detail view inside visual studio. The place where I am embedding this is a custom section inside the build summary. I implemented this custom section as a VisualStudio Plugin. Here is a picture:

enter image description here

The section "Release Build" is custom-made and will provide information about an email that will be send to everyone, once such a build is released.

The Changeset 627 inside this section is a Button control that has automatically been transformed into a link. The "Click"-Handler behind the button works. The code currently looks like this:

...
string link = buildDetailView.TeamProjectCollection.Uri.AbsoluteUri.Substring(0, buildDetailView.TeamProjectCollection.Uri.AbsoluteUri.LastIndexOf('/'));
link += "/web/UI/Pages/Scc/ViewChangeset.aspx?changeset=";
link += ((Button)sender).Content;

Process.Start(new ProcessStartInfo(link));
e.Handled = true;
...

This code will open a new Browser tab and show the correct page. However, I would like it to open the changeset detail inside Visual Studio. Just like the button at the bottom in section "Associated Changesets" does. When you click on the link "Changeset 627", it will open that changeset inside Visual Studio.

EDIT 1

It may be a bit clearer what exactly the desired outcome is, if I post a picture of it. The "Changeset Details" Window is what I would like to open using the API.

enter image description here

like image 309
Christian Avatar asked Jan 17 '12 07:01

Christian


People also ask

How do I open changeset in Visual Studio?

In Solution Explorer or Source Control Explorer, browse to the folder or file, open its shortcut menu, and choose View History. In the History window, select the row that contains the changeset for which you want to view details, open its shortcut menu, and then choose Changeset Details.

How do I view changeset details in TFS?

Take searching for a changeset in Visual Studio's TFS Source Explorer. Luckily if super easy to do! When you're in the Source Explorer, simply press Ctrl + G and the Find ChangeSet dialog will appear. From here you can type the changeset number and press OK.


1 Answers

Take a look at the following blog posts:

  • Ed Hintz: How to write a Team Foundation Version Control Add-In for Visual Studio
  • Brian Harry: Working on TFS SDK improvements and TFSAddin.zip sample code (ZIP file includes a doc on the API as well)

Essentially, you need references to the following assemblies:

 Microsoft.TeamFoundation.Client
 Microsoft.TeamFoundation.VersionControl.Client
 Microsoft.TeamFoundation.VersionControl.Controls
 Microsoft.VisualStudio.TeamFoundation
 Microsoft.VisualStudio.TeamFoundation.Client
 Microsoft.VisualStudio.TeamFoundation.VersionControl

Then you can use VersionControlExt.ViewChangesetDetails(int changesetId) to display a specific changeset from your add-in:

VersionControlExt vce;
vce = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
vce.ViewChangesetDetails(changesetId);

This brings up a dialog that shows the user all the details about a particular changeset. (It is the same dialog that appears if the user selects "Details..." in the "Find Changesets" dialog.)

like image 143
Grant Holliday Avatar answered Nov 01 '22 22:11

Grant Holliday