Visual Studio 2017 在哪里存储它的配置?

Where does Visual Studio 2017 store its config?

在 VS 2015 及更早版本中,设置存储在注册表中,例如HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio.0_Config。根据 this post.

,在 VS 2017 中,为了支持 VS 的多个实例,设置已移出注册表

根据 this SO answer,我之前一直在编辑注册表以在 Windows 处于高对比度模式时强制使用深色主题。现在我想在 VS 2017 中做同样的事情,但找不到设置的存储位置,无法进行此更改。

Visual Studio 2017 年的这些设置存储在哪里?

通过检查来自 Process Monitor 的日志,您可以看到它检查相同的注册表项。

只是没有创建。您需要创建它。名称的一部分 (e3d5273c) 在您的计算机上可能有所不同。

我在this blog post中找到了答案:

See how empty is the regular HKEY_CURRENT_USER\Software\Microsoft\VisualStudio.0 key on my machine and notice that there is no 15.0_Config key:

Instead, the VS 2017 private registry is stored in your AppData folder:

Fortunately, you can use regedit.exe to load a private hive. You need to select the HKEY_USERS node, and click the File > Load Hive… menu. You select the privateregistry.bin file, give a name to the hive (I entered “VS2017PrivateRegistry”) and now you can see the 15.0_Config key populated as usual (note: use File > Unload Hive when done):

使用本指南,我能够加载私有注册表,从 the SO answer mentioned earlier 进行更改,卸载配置单元并使用深色主题启动 VS 2017!

编辑:我不得不稍微修改我用来编辑注册表的 PowerShell 脚本,如果有人感兴趣,这里是更新版本:

EDIT2:现在修改为包括自动加载私有注册表,包括垃圾收集以允许卸载配置单元:

注意:用户名(C:\Users\Geir)和VS版本(15.0_8165452c)你必须自己找到正确的路径。

New-PSDrive HKU Registry HKEY_USERS

reg load 'HKU\VS2017PrivateRegistry\' "C:\Users\Geir\AppData\Local\Microsoft\VisualStudio.0_8165452c\privateregistry.bin"

$HighConstrastTheme = "HKU:\VS2017PrivateRegistry\Software\Microsoft\VisualStudio.0_8165452c_Config\Themes\{a5c004b4-2d4b-494e-bf01-45fc492522c7}"
$DarkTheme = "HKU:\VS2017PrivateRegistry\Software\Microsoft\VisualStudio.0_8165452c_Config\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}"

Remove-Item -Path $HighConstrastTheme -Recurse
Copy-Item -Path $DarkTheme -Destination $HighConstrastTheme -Recurse

[gc]::collect()

reg unload 'HKU\VS2017PrivateRegistry'

我已经实施了一种基于批处理文件的方法,该方法可以自动执行所有操作,还可以备份高对比度主题,以防您出于任何原因需要恢复它。

您可以在 https://randomshaper.blogspot.com.es/2017/06/visual-studio-2017-high-contrast-hack.html

找到它

以下 VS2017PrivateRegistry.cmd 批处理文件将所有 Visual Studio 2017 实例的注册表项加载为 HKLM_TMPVS_[id],启动注册表编辑器以便您在 Visual Studio 中进行更改关闭注册表编辑器时设置和卸载密钥:

for /d %%f in (%LOCALAPPDATA%\Microsoft\VisualStudio.0_*) do reg load HKLM\_TMPVS_%%~nxf "%%f\privateregistry.bin"
regedit
for /d %%f in (%LOCALAPPDATA%\Microsoft\VisualStudio.0_*) do reg unload HKLM\_TMPVS_%%~nxf

注意:首先关闭 运行ning Visual Studio 2017 个具有后台进程的实例,然后 运行 使用管理员权限关闭此文件。

有关详细信息,请参阅 Changing Visual Studio 2017 private registry settings

真正解决这个问题的方法是让 Visual Studio 团队允许开发人员设置主题。如果您有兴趣解决此问题,请转到此 VS 问题报告并关注它并发表评论支持它。目前正在考虑中。

Visual Studio forces the user to use its High Contrast theme when Windows is in High Contrast mode