Search code examples
visual-studio-2010visual-studio-2012visual-studio-2013restartvisual-studio-extensions

Restart visual Studio with same project


Often when you install a Visual Studio Extension to Visual Studio 2012 it gives you an option to restart (with the same project open and just as you left it).

Is there a way to MANUALLY restart Visual Studio with the same project open, for when VS starts running like a dog and intellisense has given up?

I see there are extensions for VS2010 and VS2013, but could not find one for VS2012.


Solution

  • You can use the following C# command with my Visual Commander extension:

    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
    {
        string vs = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
        string solution = DTE.Solution.FullName;
        DTE.ExecuteCommand("File.SaveAll");
        DTE.ExecuteCommand("File.Exit");
        System.Diagnostics.Process.Start(vs, '"' + solution + '"');
    }