TFVC in Visual Studio Extension

There is no shortcut that can be used to "Get Latest" for the entire solution when working with TFS version control. And after searching the web for a while, I got to the conclusion that the only way to add it, is to build a Visual Studio extension. Unfortunately, it's hard to find documentation about manipulating TFVC from extension. So I have opened the code of the great "Locate in TFS" extension.

The way to interact with TFVC is to get the VersionControlExt object. VersionControlExt have SolutionWorkspace property which in turn have the Get method which is used to get latest for the entire solution.

var vce = _dte.GetObject(
	"Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt");
  
vce.SolutionWorkspace.Get();
  

The main problem with this code is that we will need to add Microsoft.VisualStudio.TeamFoundation.VersionControl.DLL as a reference. But since each Visual Studio version might have a different DLL version, it will be much easier to dynamically invoke this method. An example can be seen in my extensions repo: KeyZ


Comments

Popular Posts