r/learncsharp • • Jul 19 '23

Where can I find common .gitignores for C# Web API projects?

I created a new Web API project using common libraries and XUnit for testing.

I'm using Rider and know some people using VSCode. I took a .gitignore file from here ( because there is no C# specific one... ? )

https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

I commented out these lines

!.vscode/settings.json
!.vscode/tasks.json 
!.vscode/launch.json 
!.vscode/extensions.json

and added the following lines

# JetBrains Rider
.idea/ *.sln.iml
# Exclude appsettings files
**/appsettings*.json
# Exclude launchSettings files
**/launchSettings*.json

but still that doesn't seem to be enough. The initial commit still tries to add a lot of files ( > 100 ) to version control, e.g.

Api.csproj.CopyComplete at Api/obj/Debug/net7.0

or

Microsoft.TestPlatform.CommunicationUtilities.resources.dll at Api.Tests/bin/Debug/net7.0/zh-Hans

Would someone mind telling me what's missing? Having a look at Go or Node I would expect an initial commit with maybe ~5 files or so.

Thanks in advance :)

1 Upvotes

4 comments sorted by

5

u/[deleted] Jul 19 '23

Just use "dotnet new gitignore" when in root of your project folder and .NET should handle it for you!