Relocate .vs folder from solution folder
Asked Answered
E

2

9

I am trying to clean up my solution folder. So far I have relocated the packages folder, which is generated by Nuget as described here: C# visual studio how to relocate nuget package folder?

I notice there is also a .vs folder, which is generated by the C# compiler (Rosyln) and is described here: .vs folder to source control in visual studio 2015?. Is it possible/advisable to relocate this folder?

Erythropoiesis answered 6/6, 2017 at 22:20 Comment(1)
.vs folder contains Roslyn cache, but that does not mean it is generated by Roslyn. Other IDE components, such as IIS Express support, also place their files there.Swamper
P
-8

I do not believe there is any way to relocate the .vs folder, but the better question is why would you need to? Since it is simply a temp file cache specific to only that solution moving it out of the scope of that folder to a different folder effectively does nothing. If there is no advantage, then why move it?

For example: When moving the NuGet folder it allows you to share the locally downloaded package cache with multiple solutions, saving disk space, network resources, and time. This has a clear advantage

If you simply need to remove that folder for cleanup purposes only (for instance to share it with someone) you can delete it at any time without any concern. It will be auto generated again the next time you build your solution, but it is not required if you just want to share your codebase.

Physician answered 6/6, 2017 at 22:37 Comment(3)
There are numerous good reasons to keep generated files out of source folders.Orlop
I have my visual studio project in OneDrive, and the .vs folder is huge.Riotous
Moving it out would stop onedrive from uploading it. Onedrive has no ignore functionality so this would be very beneficial.Winfield
B
0

There's one .vs folder per .sln file next to the .sln file, that defines the organization of projects in the solution (or sub-solution) in quite a readable fashion. Hacks to clean the solution folder from the cache(s) held in the .vs folder(s):

A) Copy the .sln file(s) out of the repo folder (and edit the project folder locations in the .sln accordingly), and the vs. folder is moved out as well. You might have to maintain a second version of every .sln file inside your repo, though. Manually.

mySolution.sln:

Project("{<ProjectGUIDi>}") = "myProject_i", "myProject_i.vcxproj", "{<ProjectTypeGUIDi>}"

mySolution_moved_out.sln:

Project("{<ProjectGUIDi>}") = "myProject_i", "<PATH_TO_mySolution_REPO>\myProject_i.vcxproj", "{<ProjectTypeGUIDi>}"

B) In terms of disk space (or for a simple include of only one root folder without exceptions in trivial local backup operations, such as the File History) you can also move the .vs folders' contents out by means of the file system. You might need admin privileges, though.

B.1a) Move the .vs folder out, and let a symbolic link point to its new location. mklink /D \\myRepo\.vs \\var\myCaches\mySolution.vs VSS won't replace the symbolic link. For any trivial local backup operations like copying the solution folder, you'll have to make sure to copy the symbolic link as a symbolic link, not to copy the contents of the linked .vs folder: copy /L robocopy /SL ...

B.1b) OneDrive would not replicate the link to .vs, but the linked content of .vs. Thus, for OneDrive the solution was the other way round: place your repo outside of the OneDrive folders, and in a OneDrive folder make a symlink tree with symbolic links to those folders or files only that you really want OneDrive to replicate.

B.2) Empty the .vs folder and mount a (virtual) disk volume onto the .vs folder. VSS will rebuild the contents of the .vs folder(s). You'll need to make sure the (virtual) disk is already mounted before running VSS, though. A fine solution for a huge .vs directory, but quite some overhead if you work with more than one single solution, or .sln file, respectively. Since you might want to relocate also the intermediate directorys to a place next to the .vs directory, you could consider a combination of (B.1) and (B.2).

Bilyeu answered 8/6 at 11:51 Comment(0)
P
-8

I do not believe there is any way to relocate the .vs folder, but the better question is why would you need to? Since it is simply a temp file cache specific to only that solution moving it out of the scope of that folder to a different folder effectively does nothing. If there is no advantage, then why move it?

For example: When moving the NuGet folder it allows you to share the locally downloaded package cache with multiple solutions, saving disk space, network resources, and time. This has a clear advantage

If you simply need to remove that folder for cleanup purposes only (for instance to share it with someone) you can delete it at any time without any concern. It will be auto generated again the next time you build your solution, but it is not required if you just want to share your codebase.

Physician answered 6/6, 2017 at 22:37 Comment(3)
There are numerous good reasons to keep generated files out of source folders.Orlop
I have my visual studio project in OneDrive, and the .vs folder is huge.Riotous
Moving it out would stop onedrive from uploading it. Onedrive has no ignore functionality so this would be very beneficial.Winfield

© 2022 - 2024 — McMap. All rights reserved.