Visual Studio 2015 creates a new folder called ".vs". What is the purpose of it and should I add it to source control?
-
1Possible duplicate of [.vs\config\applicationhost.config in source control](http://stackoverflow.com/questions/30363172/vs-config-applicationhost-config-in-source-control) – Michael Freidgeim Mar 21 '16 at 00:55
-
2@MichaelFreidgeim: Not sure, the other question asks about a specific file and this is about the whole folder. But it happens that some of the broader answers fit both. – SoftwareFactor Mar 21 '16 at 17:36
3 Answers
No, you should not add it to source control. The purpose of this folder is to move machine- and user-specific files to a central location. The explanation on the Visual Studio User Voice issue explains it well:
So far, we have moved the .SUO file and the VB/C# compiler IntelliSense database files to the new location. All new project specific, machine local files will be added to the new location too. We plan on taking this even further in future releases and are investigating how to improve the directory structure of build output and other existing files that can clutter the source tree.
These are all files that you would never check in, since they are generated from a build or contain machine-specific information.

- 23,334
- 2
- 57
- 88
-
25That's kind of a broad stroke to say don't checkin the whole folder. If your website requires specific IIS Express configs (like using a hostname for cookies to work), checking in the `applicationhost.config` helps other devs in setting up their environment, otherwise each one has to do it on their own and they probably find it out the hard way. – Mrchief Oct 12 '15 at 18:59
-
3@Mrchief I'm not an IIS developer, but I believe [this answer](http://stackoverflow.com/a/30368937/1698557) address that. – Patrick Quirk Oct 12 '15 at 19:45
-
2That answer is really not a solution, more of an workaround (which the answer itself alludes to). What I was trying to say was that a binary answer may not be enough for everyone. Depending on your setup, you may have to exclude the folder but then add an exception for the `applicationhost.config` file or something towards that effect. – Mrchief Oct 12 '15 at 19:48
-
4@Mrchief: Actually that's no workaround, this is the best solution. I don't think you should ever checkin the .vs folder, it is not intended to be. – D.R. Jan 11 '16 at 08:00
-
@D.R. I bet hammers are not intended to be used to crack coconuts, but they might solve the problem just as well. – Alex Mar 08 '16 at 21:34
-
6As the cited answer of lugberk states: "there is no way to tell ASP.NET 5 projects to look for this today". Because of that, I don't see any other option to share those IIS Express configuration settings between ASP.NET 5 projects than that of checking in the applicationhost.config file under .vs. Or do you see any other / better solution? – Gustin May 23 '16 at 12:00
-
@Gustin - There's nothing stopping you from temporarily allowing check ins of the file and then adding to gitignore after. Git will still pull down the file but changes will be ignored. I can't think of a scenario where you'd need to change this file on a regular basis. – Spencer Ruport Sep 15 '16 at 14:33
-
Excluding the .vs folder also excludes the .suo file which includes any run configurations that you have set up. This is a common scenario when you want to white-label your app and decide to not use multiple projects for this purpose. – Joris Weimar Nov 01 '17 at 05:38
-
-
@SpencerRuport - it doesn't make any difference whether it is in the .gitignore before, after or not at all. You can force a check in per Jim Wollff's answer below if it is in the gitignore, and if you have checked it in, the fact that it is in .gitignore is irrelevant, git will stil notice changers and check them in with for example git add -u. To fix that you can use git --skip-worktree like this answer https://stackoverflow.com/a/13631525/8088084 – Mic Jan 08 '20 at 20:07
Github provides alot of .gitignore templates. In their template for visual studio they have ignored the .vs folder. Snippet from the template on github.
# Visual Studio 2015 cache/options directory
.vs/

- 11,077
- 3
- 36
- 46
-
3That can help someone to decide (lazily), but does not give strong advise or any reason to do so. The title ("Visual Studio 2015 cache/options directory") helps more in deciding. – Mohammad Dehghan Nov 27 '16 at 06:58
-
1
As described in the quote taken from uservoice in Patrick's answer, the folder is not intended for source control.
However like comments also point out, there can be some cases where you would want to include specific files from the folder.
I would add this to .gitignore:
.vs/
And then use whatever git tool you prefer to add certain files like a shared configuration of the applicationhost.config if needed.
Or use a git command like this:
git add -f .vs/config/applicationhost.config
This way git adds the file, even if it is ignored.

- 5,052
- 5
- 34
- 44
-
4I would like to add that if you're using TFS, you can use the negate prefix in your .tfignore file to "re-include" an applicationhost.config file after excluding the .vs folder. The default .tfignore file explains it like this: "The ! prefix negates a pattern. This can be used to re-include an item after it was excluded by a .tfignore file higher in the tree, or by the Team Project Collection's global exclusions list." – Aaron Jan 01 '18 at 23:58