Mercurial .hgignore for Visual Studio 2008 projects
Asked Answered
G

7

166

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/
Garfish answered 29/8, 2008 at 17:17 Comment(2)
Side note: I think the .sln files should not be excluded from source controlWatercool
Slavo, you are correct. Solution files (.sln) contain the structure of your projects, so you'll want to include those in your repository.Elka
E
209

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
Elka answered 13/4, 2009 at 15:54 Comment(6)
No, but they have the same concept of an ignore file.Elka
@sebastiaan Only if the OP accepts his own answer: meta.stackexchange.com/questions/23049/… (and thanks!)Elka
@Nate This has been here a year and you're the first to notice that. Good catch! Updated to [Dd]ebug.Elka
I was looking for the ignore code that Rob Connery used in his Mercurial for Codeplex Tekpub video and it matched this exactl. Great job!Indisposition
For me this meant a file called Debug.Something.dll.config was ignored, so I think the trailing / on [Dd]ebug*/ doesn't have the desired effect. Perhaps for windows it should be [Dd]ebug*\ ?Knobby
For me this meant a file called Debug.Something.dll.config was ignored, so I think the trailing / on [Dd]ebug*/ doesn't have the desired effect. I think the problem is with the glob-style syntax not correctly matching on directories. If you take out the Debug and Release lines and replace them with three new lines at the bottom of the file: syntax: regexp and [Rr]elease.*/ and [Dd]ebug.*/ then it seems to work correctly.Knobby
C
37

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.

Colostomy answered 29/8, 2008 at 17:29 Comment(2)
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.Jointworm
I always thought you needed .suo for it, thanks for the tip. We had conflicts all the time on it.Moritz
D
25

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. It also has some ignores for modern (c.2015) web development.

syntax: glob

* - [Cc]opy
* - [Cc]opy/
* - [Cc]opy (?)/
* - [Cc]opy.*
* - [Cc]opy (?).*
**/.*
**/scss/*.css
*.*scc
*.FileListAbsolute.txt
*.aps
*.bak
*.bin
*.[Cc]ache
*.clw
*.css.map
*.eto
*.exe
*.fb6lck
*.fbl6
*.fbpInf
*.ilk
*.lib
*.log
*.ncb
*.nlb
*.nupkg
*.obj
*.old
*.orig
*.patch
*.pch
*.pdb
*.plg
*.[Pp]ublish.xml
*.rdl.data
*.sbr
*.scc
*.sig
*.sqlsuo
*.suo
*.svclog
*.tlb
*.tlh
*.tli
*.tmp
*.user
*.vshost.*
*.docstates
*DXCore.Solution
*_i.c
*_p.c
__MVC_BACKUP/
_[Rr]e[Ss]harper.*/
_UpgradeReport_Files/
Ankh.Load
Backup*
[Bb]in/
bower_components/
[Bb]uild/
CVS/
[Dd]ebug/
[Ee]xternal/
hgignore[.-]*
ignore[.-]*
lint.db
node_modules/
[Oo]bj/
[Pp]ackages/
PrecompiledWeb/
[Pp]ublished/
[Rr]elease/
svnignore[.-]*
[Tt]humbs.db
UpgradeLog*.*
Definiendum answered 31/3, 2010 at 18:21 Comment(1)
+1, yours is using Debug/, so will not ingore "Debug.something.cs"Mural
S
11

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.
Sherlynsherm answered 22/10, 2008 at 15:58 Comment(0)
C
8

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

Colourable answered 19/2, 2010 at 4:15 Comment(0)
S
4

some others I use:

output
PrecompiledWeb
_UpgradeReport_Files

#Guidance Automation Toolkit
*.gpState
#patches
*.patch
Smithsonite answered 5/4, 2010 at 13:24 Comment(0)
F
3

Here are a couple pesky ones: Matlab and Excel/Office autosaves.

# use glob syntax
syntax: glob

# Matlab ignore files
*.asv

# Microsoft Office
~$*

If I accidentally add them and then close the real file that was open, Excel and/or Matlab will delete the auto-save and then Mercurial will be stuck wondering where they went. I'm sure there are other programs that do similar things.

Flapdoodle answered 17/10, 2011 at 18:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.