-
-
Save hyeomans/6281804 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Infer On | |
Option Compare Text | |
Imports System | |
Imports EnvDTE | |
Imports EnvDTE80 | |
Imports EnvDTE90 | |
Imports EnvDTE90a | |
Imports EnvDTE100 | |
Imports System.Diagnostics | |
Imports System.IO | |
Public Module OpenInPowerShellModule | |
Public Sub OpenPowerShellHere_Solution() | |
Dim directory = Path.GetDirectoryName(DTE.Solution.FullName) | |
OpenPowerShell(directory) | |
End Sub | |
Public Sub OpenPowerShellHere_Project() | |
Dim activeProject = GetActiveProject() | |
Dim directory = Path.GetDirectoryName(activeProject.FileName) | |
OpenPowerShell(directory) | |
End Sub | |
Public Sub OpenPowerShellHere_ProjectItem() | |
Dim x As UIHierarchyItem = DTE.ToolWindows.SolutionExplorer.SelectedItems(0) | |
Dim item As ProjectItem = x.Object | |
Dim directory = Path.GetDirectoryName(item.FileNames(0)) | |
OpenPowerShell(directory) | |
End Sub | |
Private Sub OpenPowerShell(ByVal directory As String) | |
Dim p = New System.Diagnostics.Process() | |
p.StartInfo = New ProcessStartInfo("C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe") | |
p.StartInfo.UseShellExecute = True | |
p.StartInfo.Arguments = "-PSConsoleFile ""C:\Program Files (x86)\Microsoft Team Foundation Server 2008 Power Tools\tfshell.psc1"" " & _ | |
"-noexit " & _ | |
"-command "". 'C:\Program Files (x86)\Microsoft Team Foundation Server 2008 Power Tools\TFSSnapin.ps1'""" | |
p.StartInfo.WorkingDirectory = directory | |
p.Start() | |
End Sub | |
Private Function GetActiveProject() As Project | |
Dim activeProject As Project = Nothing | |
Dim activeProjects() As Object = DTE.ActiveSolutionProjects | |
If activeProjects IsNot Nothing AndAlso activeProjects.Length > 0 Then | |
activeProject = CType(activeProjects.GetValue(0), Project) | |
End If | |
Return activeProject | |
End Function | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment