.NET .gitignore template
The .NET template ignores build directories, NuGet packages and Visual Studio user state, and adds launchSettings.json, which is a genuine judgement call.
At a glance
- Category
- Framework
- Patterns in this template
- 20 rules, plus 4 comment lines
- Directories ignored
- 10 of the 20 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes, though the Visual Studio rules cover a fair amount of Windows tooling noise.
- Typical companions
- C# for the wider Visual Studio rules, plus an OS template.
In detail
launchSettings.json is what separates this template from its C# sibling, and it is not an obvious call. The file defines launch profiles: which URLs the development server binds to, which environment variables are set for each profile, whether the browser opens. It lives under Properties and it is genuinely useful to share, so that a new developer gets a working run configuration.
The argument for ignoring it is the environment variables block. It is a convenient place to put a connection string or an API key while developing, and once someone does that, the file is a secret. Teams that keep it tracked usually pair that with a rule that secrets go in the user secrets store instead, which lives outside the repository entirely.
bin and obj are the standard output directories, written with bracket character classes so the rules work regardless of which case the tooling produced. obj holds the restore graph and generated assembly attributes and embeds absolute paths, which makes a committed copy actively harmful rather than merely large.
The NuGet rules cover *.nupkg and *.snupkg, the package and symbol package produced when you pack a library, plus the older packages directory. Modern projects restore into a global cache in the user profile, so that directory often never appears.
The user specific rules are .vs, *.suo, *.user, *.userosscache, *.rsuser, *.userprefs and *.sln.docstates. These are all one developer's editor state: open documents, breakpoints, window layout, per project debug settings. Committing them means everyone inherits someone else's window arrangement and fights over it in every merge. None of them are read by the build, so nothing is lost by keeping every one of them out of the repository.
Examples
# Build results
[Dd]ebug/
[Rr]elease/
x64/
x86/
[Aa][Rr][Mm]/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# NuGet
*.nupkg
*.snupkg
**/[Pp]ackages/*
# Visual Studio
.vs/
*.suo
*.user
*.userosscache
*.sln.docstates
launchSettings.json
# User-specific
*.rsuser
*.userprefs24 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- Ignoring launchSettings.json means a fresh clone has no run profile and the project starts on a random port. Consider tracking it and keeping secrets in the user secrets store instead.
- The bracket classes only cover the first character, so a directory named BIN in full uppercase is not matched.
- This template omits the TestResults rule that the C# template carries, so test run output is not covered unless you add it.
Try it: .gitignore Generator
Pick one or more templates, tick the common additions you want, and copy or download the combined .gitignore.
.gitignore Generator
LOCAL · Browser-OnlyGenerate comprehensive .gitignore files by combining templates for languages, frameworks, IDEs, and operating systems
Language
Framework
IDE
OS
Build Tool
Infrastructure
Common Additions
Preview
Select templates or common additions to generate a .gitignore file.
Related .gitignore templates
All .gitignore templates →C# .gitignore template
Why the C# template writes [Bb]in instead of bin, what the NuGet and Visual Studio rules cover, and which per developer files it keeps out of the repository.
Windows .gitignore template
What the Windows template covers: the thumbnail caches Explorer writes into image folders, the folder view settings file, and installer package extensions.
Unity .gitignore template
The Unity template ignores the import cache, temporary build state and the IDE project files the editor regenerates, using bracket classes for case safety.
Flutter .gitignore template
The Flutter template adds generated plugin manifests and per platform build artefacts to the Dart rules, including the iOS pod directory and build modes.
Unreal Engine .gitignore template
The Unreal template ignores compiled binaries, the intermediate build tree, the derived data cache and the saved directory, plus generated project files.
VS Code .gitignore template
This template ignores the .vscode folder's contents but keeps five files back on purpose, which is the clearest statement of the commit or ignore argument.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS