RSS Log in
 

Some time ago, while reinstalling StyleCop for ReSharper, I had to restart Visual Studio in order to reload the add-in. I then realised that restarting VS actually requires quite a lot of ‘clicking’ around. First you have to exit the editor, then you need to launch Visual Studio again and finally you have to re-open the solution you were working on just before you closed the IDE. This did not seem very efficient and, a quick macro later, I had a way to restart VS easily with one single click.

Public Sub RestartVisualStudio()
    Dim solution As String = DTE.Solution.FullName
    DTE.Solution.Close(True)
 
    If String.IsNullOrEmpty(solution) Then
        solution = String.Empty
    Else
        solution = """ """ & solution
    End If
 
    Dim process As System.Diagnostics.Process = New System.Diagnostics.Process()
    Dim arguments As String = "/c start """" /high """ & DTE.FullName & solution & """ /nosplash"
    process.StartInfo = New ProcessStartInfo("cmd.exe", arguments)
    process.StartInfo.UseShellExecute = False
    process.StartInfo.CreateNoWindow = True
    process.Start()
 
    DTE.Quit()
End Sub

As restarting VS is not something I do that often, I just added a restart button on my custom toolbar.

Restart Visual Studio

Ok. I promise this is my last post on Visual Studio macros… for 2009 :)


Comments are closed
© Copyright 2012 TheBooleanFrog Powered by: BlogEngine.NET|Credits|Subscribe via RSS

Follow

twitter linkedin linkedin rss

TheBooleanFrog

Programming sticky notes and other distractions...