简体   繁体   中英

Distributing open-source C# .NET code - what parts of the solution to check in?

I'd like to check in some C# .NET code to a new repository I've created on GitHub.

Usually we code in PHP/Python, in which case we'd just check in all of the .php or .py scripts and be done with it.

For my C# project, there's all of these extra files:

  • .sln
  • .csproj
  • obj/
  • bin/

To make this useful to other people, do I check all of those files in too? Or are these files specific to my computer, and shouldn't be in git/svn?

The gitignore file will usually be set up to ignore the obj/ and bin/ folders but you should upload the .sln which is the solution file and the .csproj which is the project file.

On github you can automatically create a .gitignore file based on the language you have coded in.

I think, yes, you should check-in *.sin and *.csproj files. Pay attention that, these file are xml based files. when you add any other new item, you need to check-in these files too.

GitHub has reasonable .gitIgnore for .NET

key files I tend to ignore

# User-specific files
*.suo
*.user
*.sln.docstates
*.sln.cache

[Bb]in
[Oo]bj

localConnectionStrings.config

The localConnectionStrings.config is good for websites where you can set web.config like:

<connectionStrings configSource="localConnectionStrings.config" />

This stops everyone overwriting everyone else's local dev database connection string when they commit (if that's how you work).

If you are not committing the bin folder, setting Nuget Package Restore is useful too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM