50

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

6
  • Surely HKEY_CURRENT_USER\Software\Microsoft\VisualStudio still exists Commented Mar 9, 2017 at 18:53
  • 2
    The key exists, but these values are gone. Commented Mar 9, 2017 at 19:02
  • This seems to come close: facility9.com/2009/06/… Commented Mar 9, 2017 at 19:34
  • Thanks folks - close but no cigar. Some directories remain despite moving the Projects/Templates folder Commented Mar 10, 2017 at 20:15
  • It should never create these folders/files in the user's documents folder in the first place. I have four of them now. 2010, 2015, 2017, and 2019. Just taking up (visual) space. Commented Mar 2, 2021 at 17:08

3 Answers 3

65

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

Sign up to request clarification or add additional context in comments.

10 Comments

Excellent - this worked perfectly. Thanks very much!
These folders were reset after a Visual Studio Repair as well, but only a 5 minute fix to load/edit/unload the hive
In Visual Studio 2017, registry settings are stored in a private location, which enables multiple side-by-side instances of the same version of Visual Studio on the same machine. Documentation location: learn.microsoft.com/en-us/visualstudio/install/…
Downvoting because I strongly believe @David's answer is concise and much better for the average user. These steps are not likely to be supported/maintained by Microsoft.
I figured it out: if you set the MyDocumentsLocation not to your real documents location, then the file will be regenerated. Otherwise it's accepted.
|
28

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

enter image description here

5 Comments

Well, the regedit of VisualStudioLocation is superior as it changes all at once including Code Snippets location. (Also, Visual Studio always creates a "My Snippets" for Visual Basic [even if you delete it], the location of which can only be changed using the regedit method.)
Yeah, the reason I even posted my answer is that just changing these settings still leaves pesky folders around that aren't removed. If you don't care about those, I agree that this is a fine answer.
Regarding "dangerous regedit", it's a separate hive from the registry entries for your entire computer, so anything that you fuck up can be easily repaired by the VS installer. (If you had actually read my answer...) It's not your typical "change a bunch of registry entries to 'fix' your computer".
This only changed the location of templates for me, not the whole "Visual Studio 2017" directory.
@chris-r-donnelly Helped my anyway as after changing whole "Visual Studio 2017" directory those two template still get autocreated.
0

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. 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.