Duodenalsalmons
Duodenalsalmons

Reputation: 652

How to change "Visual Studio 2017" folder location?

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:

Directories in My Documents

Upvotes: 50

Views: 42340

Answers (3)

Ernest3.14
Ernest3.14

Reputation: 1012

(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.

Upvotes: 64

Jaggan_j
Jaggan_j

Reputation: 518

If you have source control enabled for the Project, in addition to the step as answered by David, you have to also map the TFS local path location to the new Project location :

In VS 2017: 
File -> Source Control -> Advanced -> Workspaces -> Edit the relevant 
Workspace -> Select the Project -> Edit path to Local Folder to be the new 
location.

Upvotes: 0

David
David

Reputation: 4083

Or (in Visual Studio 2017) just go to tools >> options >> projects and solutions >> Locations

enter image description here

Upvotes: 28

Related Questions