如何更改“Visual Studio 2017"文件夹位置? [英] How to change "Visual Studio 2017" folder location?

查看:132
本文介绍了如何更改“Visual Studio 2017"文件夹位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改在 %USERPROFILE%/Documents 下创建的Visual Studio 2017"目录的位置?

在 2015 年及更早版本中,您可以通过编辑注册表将所有文件夹移出我的文档",但这些值似乎已在 VS2017 中移动:

旧方法::

<块引用>
  • 以前,Visual Studio 将许多注册表项安装到系统的 HKEY_LOCAL_MACHINEHKEY_CURRENT_USER 配置单元中的 Visual Studio 特定项下:
    • HKLM\Software\Microsoft\VisualStudio\Version:[...]
    • HKCU\Software\Microsoft\VisualStudio\Version:[...]
    • HKLM\Software\Microsoft\VisualStudio\Version_Config:[...]
  • 为了减少对注册表的影响,Visual Studio 现在使用 RegLoadAppKey 函数将注册表项存储在 %VsAppDataFolder%\privateregistry.bin 下的私有二进制文件中.[...]

所以本质上,您需要做的是找到该文件,将其加载到注册表编辑器(例如 regedit.exe)中,根据自己的喜好更改值,然后保存相同格式的文件.在我的机器上,该文件位于:

C:\Users\Ernest\AppData\Local\Microsoft\VisualStudio\15.0_dfee2c30

不审查我的用户名,因为这很明显.下面是如何使用regedit.exe进行

首先,选择某个地方来加载注册表配置单元(我使用了HKEY_USERS).只要您在加载配置单元时不覆盖某些内容(它会警告您),这并不重要.选择该密钥后,转到 File > Load Hive...,然后打开上述 privateregistry.bin 文件.输入密钥名称以将其加载(例如VS2017_config"),您将看到过去版本中用于配置路径的熟悉密钥.改变那些.完成后,选择您加载的配置单元(例如VS2017_config"),然后转到 File > Unload Hive....这应该正确设置文件夹路径.

<小时>

请注意,这些文件夹会在您第一次使用 Visual Studio Blend 时再次弹出,因此如果您打算使用它,请记住也要更改这些文件夹.

编辑:Blend 的相应注册表配置单元为我提供:

C:\Users\Ernest\AppData\Local\Microsoft\Blend\15.0_dfee2c30

<小时>

Edit 2018:@ofthelit 善意地发布了 官方页面 包含相关信息.

How do you change the location for the "Visual Studio 2017" directory that is created under %USERPROFILE%/Documents?

In 2015 and earlier, you could move all the folders out of "My Documents" by editing the registry, but those values seem to have moved for VS2017:

The old way: Change "Visual Studio 2010" folder location

Update

I have changed the default Projects and Templates locations, but these directories persist in My Documents:

解决方案

(Starring this question because I'm going to need this answer for the next release of Visual Studio, I bet... And I forget this every time I set up a new machine. I cobbled this together last time from a bunch of different sites, but unfortunately my google-fu cannot find them again, so my sincerest gratitude to those unnamed developers.)


Finally, a question I can answer! I, too, have spent countless hours trying to fix this. The commenter on your question is correct--the settings are still controlled by the same registry keys, it's just that the location of those has been moved following the switch to a different installer. Lo and behold:

  • Previously, Visual Studio installed many registry keys into the system’s HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER hives under a Visual Studio-specific key:
    • HKLM\Software\Microsoft\VisualStudio\Version: [...]
    • HKCU\Software\Microsoft\VisualStudio\Version: [...]
    • HKLM\Software\Microsoft\VisualStudio\Version_Config: [...]
  • To reduce the impact on the registry, Visual Studio now uses the RegLoadAppKey function to store registry keys in a private binary file under %VsAppDataFolder%\privateregistry.bin. [...]

So in essence, what you need to do is to find that file, load it in a registry editor (such as regedit.exe), change the values to your liking, and then save the file in the same format. On my machine, the file was located in:

C:\Users\Ernest\AppData\Local\Microsoft\VisualStudio\15.0_dfee2c30

Not censoring my username 'cause it's pretty obvious anyway. The following is how to use regedit.exe to do the editing:

First, select somewhere to load the registry hive (I used HKEY_USERS). It doesn't really matter as long as you don't overwrite something when loading the hive (it will warn you). With that key selected, go to File > Load Hive..., and open the aforementioned privateregistry.bin file. Type in a Key Name to load it under (e.g. "VS2017_config"), and you'll see the familiar keys used in past versions to configure paths. Change those. When you're finished, select the hive which you loaded (e.g. "VS2017_config"), and go to File > Unload Hive.... This should set folder paths correctly.


Do note that those folders will pop up again the first time you use Visual Studio Blend, so remember to change those as well if you ever plan on using that.

Edit: The corresponding registry hive for Blend was here for me:

C:\Users\Ernest\AppData\Local\Microsoft\Blend\15.0_dfee2c30


Edit 2018: @ofthelit has kindly posted an official page with the relevant info.

这篇关于如何更改“Visual Studio 2017"文件夹位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆