Wednesday, July 25, 2007

So often In Visual Studio  find myself needing to get to a DOS prompt with the directory set to the current solutions folder.   Strangely I find I do this with alarming regularity.

So today I just created a quick macro in visual studio that I've added to my main toolbar.

 

image

Here's the source

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module RJMacros
    Public Sub OpenDos()

        Dim currentSlnFolder As String

        currentSlnFolder = DTE.Solution.FullName
        REM currentSlnFolder = DTE.ActiveDocument.Path
        If (String.IsNullOrEmpty(currentSlnFolder)) Then

            Return
        End If

        Debug.Print(currentSlnFolder)
        Dim lastpos = currentSlnFolder.LastIndexOf("\")
        currentSlnFolder = currentSlnFolder.Substring(0, lastpos)
        currentSlnFolder = """CD /d " + currentSlnFolder + """"
        Shell("cmd /K " + currentSlnFolder, AppWinStyle.NormalFocus, False, -1)
    End Sub
End Module

 

Of course the same could be used with minor modification for opening PowerShell.

Wednesday, July 25, 2007 1:05:15 PM UTC  #    Comments [0]  | 

Theme design by Jelle Druyts

Pick a theme: