Visual Studio 2019 – Comparing settings to default settings - visual-studio

Visual Studio 2019 can be configured in many ways via settings. Is there a simple way to find out which settings differ from the default settings?
I’m looking for a similar method as Open Settings (JSON) in Visual Studio Code. Open Settings (JSON) in Code only contains the options which differ from the defaults.
What I have tried is the comparison between the exported settings from a new workstation and from an existing one, but the exported xml files contain too much noise.

Related

Reset Visual Studio 2022 Extension to its default settings

I am the user (not the developer) of a Visual Studio 2022 extension which correctly uses the built-in WritableSettingsStore to store its settings (I verified this by looking at the extension's source code).
After extensively playing around with the extension's settings, I would like to restore it to its original state. Uninstalling and reinstalling didn't help, my modified settings were retained. I also don't want to reset all my Visual Studio settings or remove my complete user profile, I just want to reset this one extension.
Hence my question:
Where does the WritableSettingsStore physically store a Visual Studio Extensions's settings?
It's stored in the same place where Visual Studio stores its own settings: in Visual Studio's private registry hive.
Open the private registry hive with regedit.exe as described in the following question. Note: The correct path for Visual Studio 2022 is %LocalAppData%\Microsoft\VisualStudio\17.0_71c0f998\privateregistry.bin.
Access Visual Studio 2017's private registry hive
The extension's settings are stored in the subkey Software\Microsoft\VisualStudio\17.0_71c0f998\NameOfTheExtension. Remove that key to reset the extension to its default settings.
Don't forget to unload the hive as explained in the link in step 1.

Export Custom Well regex in Productivity Power Tools

Is there any way to export the coloring rules for the Productivity Power Tools's component: Custom Well?
I have quite a sophisticated configuration and it's always a pain to move it to another computer or to the new version of Visual Studio.
I have tried to export this particular setting using the Import and Export Settings of Visual Studio, but cannot locate it there. At he same time, I would prefer not to export/import all the VS settings.
I guess that would be a simple copy paste of one file, but not sure where to look for it.
Copy pasting row by row is the last resort, as for each of the colors you need to manually choose it in the picker (terrible design).
After further research I have found out that the color/regex settings are stored within the registry, under:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\DialogPage\Microsoft.CustomDocWell.Options\Colors
(for Visual Studio 2015; for the earlier versions, change 14.0 to the desired version number). Those registry settings can be simply exported/imported as any other.
However, the situation differs with the Visual Studio 2017, where the registry structure has been changed. The keys are still there, but it gets a bit more complex to get there. You can read more on the topic here:
https://visualstudioextensions.vlasovstudio.com/2017/06/29/changing-visual-studio-2017-private-registry-settings/
In VS 2017, you'll have to follow the instructions in
https://visualstudioextensions.vlasovstudio.com/2017/06/29/changing-visual-studio-2017-private-registry-settings/
given by mikus, then the Regex will be in the key like:
HKEY_LOCAL_MACHINE\_TMPVS_15.0_116e7493\Software\Microsoft\VisualStudio\15.0_116e7493\DialogPage\Microsoft.CustomDocWell.Options\Colors
But NOTE : you may have to add a new regex in visual studio options (Productivity Power Tools -> Custom Document Well -> Color Coding) before this key shows up.

How to silently provide initial settings for Visual Studio

I'm looking for a way to provide initial settings for Visual Studio 2017 through a script. Copying a *.vssettings file to the %USERPROFILE%\Documents\Visual Studio 2017\Settings path doesn't work since Visual Studio will rewrite the file on startup while creating a user profile.
There is the /resetsetting switch vor devenv.exe which can be used to reset the settings to a specified .vssettings file, but this will also open Visual Studio IDE.
Is there a way to silently provide initial settings for Visual Studio from a PowerShell script? Or any safe way to detect at which time Visual Studio has created the profile and imported the settings when using /resetsetting, so that the devenv process can be killed?
When using /resetsettings, you could:
Check whether default settings file exists. Get modified date if it does.
Run devenv.exe /resetsettings <filepath> The modified date on the default settings file will be changed to match the file specified.
Check modified date has changed, or file now exists.
Close devenv.exe
I've given this a go; the settings file after step 3 isn't identical to the one specified in /resetsettings, although it's clearly different from the previous default one. I don't know the criteria for which tags are kept.
Related, not a PowerShell solution: A team settings file can be specified by going to Tools > Options > Environment > Import and Export Settings. More info on Enviornment Options.
Note from link: "When applied, these team settings would not override any category not specified in the .vssettings file"

How to use different tab settings in different projects in Visual Studio

The Visual Studio options dialog allows you to set tab preferences (size, insert-spaces, etc.) on a per-language basis. But I am regularly working on a couple of c# projects with different settings for these values.
Is there a way to override the global settings on a per-project basis, or at least toggle between them easily?
Another approach may be through the extensibility API: it should be possible to write a macro or add-in that changes these settings.
E.g. to change the tab size to 6, use the following:
DTE.Properties("TextEditor", "CSharp").Item("TabSize").Value = 6
Here's a link that explains how to find out the names of the properties: http://support.microsoft.com/kb/555445
You can open visual studio with a special "reset" settings file which overrides the default settings. Using this method it is possible to create two shortcuts, one with each tab setting. Details are here.
I'm afraid you can't do that on a per-project basis.
But, with Tools/Import and Export Settings... you can export each settings in a file and you could import the one that fits your current project.
Visual studio 2017 adds .editorconfig support, which is very handy for such settings.

How to Export/Import Toolbars in Visual Studio

I export my settings in Visual Studio and if I ever move to a new machine or have problems, I use those backed up settings to restore Visual Studio to the way I like it. It also allows me to maintain a consistent development environment between the various machines that I use.
This works great for keybindings, syntax highlighting, user tools, pretty much everything except for the toolbar locations and customizations. Whenever I move to a new machine and restore the settings, the toolbars are not affected. I have spent a fair amount of time setting up toolbars with my macros, external tools, etc and cut'n'pasted icons in for them. I hate losing all that work.
Does anybody know how to back up and restore the toolbars' locations and customizations? If it is not a feature of Visual Studio, is there an addin that will do the job?
Edit
As mentioned below, the Menu and Command Bar Customizations in Import and Export Settings is supposed to do this, but when I re-import my previous settings, I get
Error 1: Menu and Command Bar Customizations: The version of command bar settings being imported is not supported. All the command bar settings have been ignored.
The settings I am trying to re-import were exported earlier this month with the same version of Visual Studio. The only difference is that I am now running 64 bit as opposed to x86. I didn't think that would make a difference though since the settings files are XML.
Any ideas?
I have finally found the solution to this. There is a known bug in Visual Studio and there are two workarounds given. The first workaround does not apply, but the second worked.
To Backup your toolbars:
Copy the file CmdUI.PRF from the path %AppData%\Microsoft\VisualStudio\X.Y\1033 to the same directory as your exported .settings file.
where X.Y is either of 8.0, 9.0, 10.0 or 11.0 depending on your visual studio version (2005, 2008, 2010 and 2012 respectively).
To Restore your toolbars:
Make sure Visual Studio is closed and copy the backed up file back to the original location.
For the benefit of others, as you mentioned this feature doesn't seem to be supported across versions of Visual Studio, presumably because of a change in the DTD/XSD for the settings file? At any rate, here's where the settings for your custom toolbars lie in the "Import and Export Settings..." dialog:
Note: Your options may look different, depending on the settings you exported.
I have not tried it, but "Tools\Import and Export Settings..." maybe will let you export a .vssettings file you can then take to another box.
See also
http://blogs.msdn.com/saraford/archive/2005/04/19/409887.aspx
and other Sara 'export' tips.

Resources