views:

5928

answers:

6

What is a good setup for .hgignore file when working with Visual Studio 2008?

I mostly develop on my own, only occasionly I clone the repository for somebody else to work on it.

I'm thinking about obj folders, .suo, .sln, .user files etc.. Can they just be included or are there file I shouldn't include?

Thanks!

p.s.: at the moment I do the following : ignore all .pdb files and all obj folders.

# regexp syntax.
syntax: glob
*.pdb

syntax: regexp
/obj/
+18  A: 

This is specific to a C# project, but I ignore these files/directories:

  • *.csproj.user
  • /obj/*
  • /bin/*
  • *.ncb
  • *.suo

I have no problems running the code in the depot on other machines after I ignore all of these files. The easiest way to find out what you need to keep is to make a copy of the folder and start deleting things you think aren't necessary. Keep trying to build, and as long as you can build successfully keep on deleting. If you delete too much, copy it from the source folder.

In the end you'll have a nice directory full of the only files that have to be committed.

Daniel Jennings
I also ignore *.config files, since my developer team all run under slightly different environments (local db instance, local email server, etc.) Also, passwords reside in the web.config.
Ash Machine
+7  A: 

Here is the content of my .hgignore for C# Visual Studio projects:

syntax: glob
*.user
*.ncb
*.nlb
*.suo
*.aps
*.clw
*.pdb
*\Debug\*
*\Release\*

A few notes:

  1. If you have custom "releases" besides "Debug" and "Release", you may need to add them.
  2. Be careful when you manually edit your .hgignore. If you make a syntax error, then hgtortoise will no longer open the commit dialog.
jm
+77  A: 

Here's my standard .hgignore file for use with VS2008 that was originally modified from a Git ignore file:

# Ignore file for Visual Studio 2008

# use glob syntax
syntax: glob

# Ignore Visual Studio 2008 files
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.lib
*.sbr
*.scc
[Bb]in
[Dd]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
Even Mien
are git and mercurial compatible???
Jhonny D. Cano -Leftware-
No, but they have the same concept of an ignore file.
Even Mien
Select, right-click, copy. That's a great list. Thanks!
Peter Bernier
If this answer has more than double the number of upvotes of the accepted answer, shouldn't this one appear first? Anyway, great answer, this is exactly what I use.
sebastiaan
@sebastiaan Only if the OP accepts his own answer: http://meta.stackoverflow.com/questions/23049/answer-with-more-upvotes-appears-above-accepted-answer (and thanks!)
Even Mien
thanks for great contribution!
realsugar
The line [Db]ebug*/ - I'm assuming that should be a lowercase d and not a lowercase b, used this ignore list as a template and took me a minute to figure out why the heck a "debug" folder wasn't being ignored :) Thanks for the great ignore file.
Nate Pinchot
@Nate This has been here a year and you're the first to notice that. Good catch! Updated to [Dd]ebug.
Even Mien
I was looking for the ignore code that Rob Connery used in his [Mercurial for Codeplex](http://tekpub.com/codeplex) Tekpub video and it matched this exactl. Great job!
Ben McCormack
+3  A: 

My Mercurial .hgignore file contents:

syntax: glob
#-- Files
*.bak.*
*.bak
thumbs.db

#-- Directories
App_Data/*
bin/
obj/
_ReSharper.*/
tmp/

#-- Microsoft Visual Studio specific
*.user
*.suo

#-- MonoDevelop specific
*.pidb
*.userprefs
*.usertasks

Keep in mind that I mainly work on WinForms, ASP.NET MVC and Mobile projects using Microsoft Visual Studio and occasionally MonoDevelop. Depending on your toolset and project types, you will probably encounter other files that should be ignored.

I try to keep the latest version on CodePaste.NET at http://codepaste.net/zxov7i

AlGonzalez
+6  A: 

I feel left out of the conversation. Here's my .hgignore file. It covers C#, C++ and Visual Studio development in general, including COM stuff (type libraries), some final builder files, CodeRush, ReSharper, and Visual Studio project upgrades.

syntax: glob

*.*scc
*.FileListAbsolute.txt
*.aps
*.bak
*.[Cc]ache
*.clw
*.eto
*.exe
*.fb6lck
*.fbl6
*.fbpInf
*.ilk
*.lib
*.log
*.ncb
*.nlb
*.obj
*.patch
*.pch
*.pdb    
*.plg
*.[Pp]ublish.xml
*.rdl.data
*.sbr
*.scc
*.sig
*.sqlsuo
*.suo
*.svclog
*.tlb
*.tlh
*.tli
*.tmp
*.user
*.vshost.*
*DXCore.Solution
*_i.c
*_p.c
Ankh.Load
Backup*
CVS/
PrecompiledWeb/
UpgradeLog*.*
[Bb]in/
[Dd]ebug/
[Oo]bj/
[Rr]elease/
[Tt]humbs.db
_UpgradeReport_Files
_[Rr]e[Ss]harper.*/
hgignore[.-]*
ignore[.-]*
svnignore[.-]*
lint.db
Damian Powell
+1  A: 

some others I use:

output
PrecompiledWeb
_UpgradeReport_Files

#Guidance Automation Toolkit
*.gpState
#patches
*.patch
rohancragg