Ejemplo n.º 1
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var vce       = (VersionControlExt)m_Dte.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt");
            var workspace = vce.SolutionWorkspace;

            var tfsServerName     = workspace.VersionControlServer.TeamProjectCollection.Uri;
            var localPath         = workspace.Folders[0].LocalItem;
            var serverPath        = workspace.Folders[0].ServerItem;
            var serverProjectName = serverPath.Substring(1).TrimStart('/').Split('/').First(); // Path starts with $ and first folder is the VSTS "Project"
            var basePath          = $"{tfsServerName}/{serverProjectName}";

            var selectedFileNames = GetSelectedFileNames();

            foreach (var fileName in selectedFileNames)
            {
                var relativePath = fileName.Replace(localPath, "").Replace("\\", "/");

                var pathParameter = Uri.EscapeDataString($"{serverPath}{relativePath}");

                var codeUrl = $"{basePath}/_versionControl?path={pathParameter}";

                CodeUrlAction(codeUrl);
            }
        }
 public TFSConnection(EnvDTE80.DTE2 _dte, ILogger _logger)
 {
     logger = _logger;
     teamFoundationServerExt = _dte.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") as TeamFoundationServerExt;
 }