10
votes

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

2
I am not 100% sure and I don't have the code right here, where I did something similar, but I think you need to take a look at the Visual Studio SDK. I'll try to remember to take a look at my old code this evening, if you didn't get an answer till then.Feroc
@Feroc thanks, I'll have a look at the SDK.Christian
+1: Very intersting. I added in a solution a simple TXT-file that contained your link http://tfs:8080/tfs/web/UI/Pages/Scc/ViewChangeset.aspx?changeset=123". When I opened it in the IDE, it opened the Changeset with CTRL+click within VS - just like you need. Is this your case as well? If not - this should be tracked in context VS-settings.pantelif
@pantelif I did the same - for me it opens the changeset details inside a new browser-tab (which is inside visual studio). What I was looking for is not a browser tab, but the item in its original user interface. I will edit my question and provide a picture of the desired user interface.Christian

2 Answers

14
votes

Take a look at the following blog posts:

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.)

0
votes

In VS 2015 you can use the following code taken from here

public void ViewChangesetDetails(int changesetId)
{
        ITeamExplorer teamExplorer = this.GetService<ITeamExplorer>();
        if (teamExplorer != null)
        {
            teamExplorer.NavigateToPage(new Guid(TeamExplorerPageIds.ChangesetDetails), changesetId);
        }
}