357

Visual Studio 2015 creates a new folder called ".vs". What is the purpose of it and should I add it to source control?

2

3 Answers 3

368

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.

10
  • 26
    That'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
    Commented Oct 12, 2015 at 18:59
  • 3
    @Mrchief I'm not an IIS developer, but I believe this answer address that. Commented Oct 12, 2015 at 19:45
  • 2
    That 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
    Commented Oct 12, 2015 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.
    Commented Jan 11, 2016 at 8:00
  • 6
    As 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
    Commented May 23, 2016 at 12:00
96

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/
2
  • 3
    That 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. Commented Nov 27, 2016 at 6:58
  • 1
    Incidentally, the same line applies to .hgignore Commented Jul 26, 2018 at 18:50
29

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.

1
  • 4
    I 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
    Commented Jan 1, 2018 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.