Skip to content

finding .gitignore file for dotnet projects

When creating a new git repository for a C# dotnet project on GitHub, I can't seem to find a preset .gitignore file for dotnet projects. I scroll through the list looking for C#, CSharp or dotnet with no luck. Guess what it is called? VisualStudio 🙃 .

> Options

Here are a few versions of the VisualStudio .gitignore file for dotnet projects.

01. VisualStudio .gitignore template on GitHub

VisualStudio template on GitHub

02. from dotnet new gitignore command

Starting from .NET Core 3.0 SDK, there a new parameter gitignore to add a dotnet .gitignore file to your project.

dotnet new gitignore

See dotnet new documentation.

03. from https://www.gitignore.io

When using https://www.gitignore.io to generate a .gitignore file for dotnet projects, you can select VisualStudio or CSharp as one of the options.

04. GitHub's gitignore repository

GitHub's own gitignore repository contains a collection of .gitignore templates for various programming languages, tools and frameworks. The VisualStudio template is the one to use for dotnet projects.

> Verdict

The .gitignore files from options listed above all contain reference to the source.

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

There are slight differences between them, but one can't go wrong with any of them. I personally would go with the one from GitHub's gitignore repository as it is (possibly) the most up-to-date.