Export/Import Visual Studio Settings from Command Line

automation, settings, visual-studio

Solution

You can achieve import by providing a settings file with the `/ResetSettings` argument.

devenv /ResetSettings c:\full\path\to\your\own.vssettings

This works from VS2005 onwards.

Although you can import from the command line, AFAIK there is no export functionality from the commandline. For that you could use a macro:

Sub ExportMacro()
    DTE.ExecuteCommand("Tools.ImportandExportSettings", "/export:own.vssettings")
End Sub 

Or from a commandline c# application (/reference EnvDte)

static void Main(string[] args)
{
     var filename = "own.vssettings";
     var dte = (EnvDTE.DTE) System.Runtime.InteropServices.Marshal.
                                GetActiveObject("VisualStudio.DTE"); // version neutral

     dte.ExecuteCommand("Tools.ImportandExportSettings", "/export:" + filename);
}

To import the from the macro and/or c# program replace /export with /import

Msdn doc

Problem

How do I export/import VS 2010/2012 settings from the Command Line or using C#? Is it even possible without resorting to GUI Automation?

Original source

Related problems