What is .vs folder in visual studio ? Can I delete it?


👤 Diwas Poudel    🕒 07 Oct 2022    📁 TECH

What is the .vs folder in Visual Studio Projects?

The .vs folder is a folder that is created automatically by Visual Studio when you create new C# projects..vs folders contain information about breakpoints, opened documents, and the current state of the solutions.

These are temporary cache files used by the Roslyn compiler for Intellisense support; they also contain IIS Express applicationHost.config files,suo files, and other files. They are usually cached content. 

Note: There is no official document mentioning about vs folder, so we're explaining it based on our own experiences and referencing various blog posts.

Where is VS folder located?

Normally these folders are hidden at the root level of your project. You have to enable showing hidden files..vs folder is usually created in the same location as you have saved a project at the solution level.

vsfolder-location
fig. vs folder location

Every other popular compiler will do an out-of-source build where all build sources are separated from intermediate-generated files. So, this will make it easy for developers for versioning, distribute and analyze sources. This seems to be a little difficult for .net as it mixes source with generated binary stuff. 

Also Read: Debug IIS-hosted web application in Visual Studio

Does the developer team create a .vs folder?

No, the developer will be unaware of it, and it will remain hidden when you, as the developer, create the application.

Can I delete vs folder?

Ans: Yes you can delete vs folder. Follow the below steps to delete vs folder.

  • Close Visual Studio Projects
  • Delete the hidden ".vs" folder located in the same folder as the ".sln" is located
  • Open Visual Studio Project
  • As soon as you open your project, the .vs folder will be automatically recreated it. If it fails to create, rebuild the projects. It also does not take long to create the .vs folder.

When you delete the vs folder, you may lose user state related to solutions such as build configurations, local debug settings, open tabs, Project Configuration such as Profile type, Launch type, and so on.

But deleting the .vs folder will not create any impact on the:

  • Solutions and projects
  • Project Dependencies files.
  • Any third-party extension used.
Also Read: Top and Best .NET CMS Platforms

What happens when you delete vs folder?

Ans: We may encounter unusual errors in error logs while developing the application, such as Error CS01124. The name 'XXXXXX' could not be found as a type or namespace... or any other related error. And this can be because of the cache .vs folder which causes IIS Express to become corrupted, and newbie developers believe it's their fault and try to find a solution, but they may not find it. So, one solution that may fix this problem is to delete the vs folder and restart and relaunch the project, which will find the problem.

Also, most of the developers have the experience that the .vs folder is large in size in GB which I used to experience about 3 years ago but don't know my case Visual Studio does not generate such large files.

Also Read: How to downgrade .net application framework version in visual studio ?

What are inside the .vs folder?

Ans: When you open .vs folders, you will find the Solution Folder, where you will get the config folder and vXX like v14,v16 folder

Inside the Config folder, you will find applicationhost.config files. It contains meta info of IIS Configuration. It can contain system.application a host, system. webserver, urlCompression, URL rewrite, WebSocket, server runtime info, authentication and authorization info, etc.

You will get applicationhost.config files only if are creating an asp.net application. For console applications or any other types of projects, you may get similar files

Inside v16, you will find .suo files. Inside .suo files, there are editorconfigGBLI files, reference info, controller info, cs files info, etc. Here, 16 is the version number of Visual Studio 2019, and the product name is usually referred to as VS2019. You may have v14 or v13 folders which depends on your Visual Studio Version.

Also Read: Best Free  asp.net hosting 

Do we have to add a .vs folder in source control?

Ans: You should not include it in source control. You can search GitHub for gitignore files for C# and find that the. vs folder has already been commented means just ignore the .vs folder. This demonstrates that you do not need to manually add it to a source control system like git.

vs-folder-in-gitignore-file
fig. vs folder commented in gitignore file for visual studio

 

 

 

Who generates the .vs folder?

The contents of the. vs folder is generated automatically by the IDE (Visual Studio). If you have multiple projects in one solution, Visual Studio will generate an a.vs folder for each project. It is located next to the .sln file.

Does Visual Studio create .vs folders automatically after they are deleted?

The answer is yes; the next time you build, the Visual Studio IDE will automatically generate it. Additionally, deleting the .vs file is occasionally required in order to allow a project to compile again.