github/gitignore · Dotnet.gitignore

.NET .gitignore Template Explained

Why Dotnet.gitignore ignores bin and obj, Debug and Release, NuGet packages, MSBuild binary logs, test results and .env, and how it differs from the VisualStudio template.

Open in generator Open with VisualStudio, VisualStudioCode, JetBrains, Windows

Dotnet.gitignore is a concise template for .NET SDK-style projects (C# and F# projects created with dotnet new). As the header comment of the template states, if you use Visual Studio it is better to add the VisualStudio template, which has many more IDE-related rules.

If you develop with VS Code, Rider or the command line, this template alone blocks most build output and tool by-products.

Rules explained

PatternWhat it ignores and why
[Bb]in/[Oo]bj/[Dd]ebug/[Rr]elease/x64/x86/bld/Build outputAssemblies and intermediate files (such as obj/project.assets.json) produced by dotnet build. The brackets catch case differences such as Bin and bin.
artifacts/project.lock.jsonproject.fragment.lock.json.NET artifactsartifacts/ is the unified output layout folder available since .NET 8, and project.lock.json is restore output from the old project.json era.
*.nupkg*.snupkgNuGet packagesPackages and symbol packages created with dotnet pack. They are artifacts published to a NuGet feed.
*.binlog[Tt]est[Rr]esult*/[Bb]uild[Ll]og.*TestResult.xmlnunit-*.xmlCodeCoverage/Logs and test resultsMSBuild binary logs (the -bl option) and test and coverage results. Binary logs can contain sensitive values such as environment variables, so be careful when sharing them.
.env~$**~Environment and temporary filesEnvironment variable files, lock files created when opening Office documents (~$document.docx), and editor backup files.

Practical notes

Original template

Dotnet.gitignore30 rules
## A streamlined .gitignore for modern .NET projects## including temporary files, build results, and## files generated by popular .NET tools. If you are## developing with Visual Studio, the VS .gitignore## https://github.com/github/gitignore/blob/main/VisualStudio.gitignore## has more thorough IDE-specific entries.#### Get latest from https://github.com/github/gitignore/blob/main/Dotnet.gitignore# Build results[Dd]ebug/[Dd]ebugPublic/[Rr]elease/[Rr]eleases/x64/x86/[Ww][Ii][Nn]32/[Aa][Rr][Mm]/[Aa][Rr][Mm]64/bld/[Bb]in/[Oo]bj/[Ll]og/[Ll]ogs/# .NET Coreproject.lock.jsonproject.fragment.lock.jsonartifacts/# ASP.NET ScaffoldingScaffoldingReadMe.txt# NuGet Packages*.nupkg# NuGet Symbol Packages*.snupkg# dotenv environment variables file.env# Others~$**~CodeCoverage/# MSBuild Binary and Structured Log*.binlog# MSTest test Results[Tt]est[Rr]esult*/[Bb]uild[Ll]og.*# NUnit*.VisualState.xmlTestResult.xmlnunit-*.xml

Templates from github/gitignore/Dotnet.gitignore @356fd7b (2026-09-11) · CC0-1.0

Often used together

More template explanations