Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are there .sln, .suo and .csproj files?

I began to use Visual Studio 2010. After I'm done with the C# program, I see that there are .sln, and .suo files in the project root directory, and a .csproj file in the subdirectory. What are those files for?

I need to identify the files to put into a Git repository. Together with the source code/documents that I create, I guess those three files are the only one that I have to take care of. However, I'm not sure if I'm tracking the correct files.

ADDED

How about the personal macro files? I have the Emacs key switch macro, does the .sln file or .csproj file have this macro?

like image 840
prosseek Avatar asked Oct 06 '10 14:10

prosseek


People also ask

What is the use of .sln file?

sln file. The . sln file contains text-based information the environment uses to find and load the name-value parameters for the persisted data and the project VSPackages it references. When a user opens a solution, the environment cycles through the preSolution , Project , and postSolution information in the .

What is a .csproj file?

What is a CSProj file? Files with CSPROJ extension represent a C# project file that contains the list of files included in a project along with the references to system assemblies. When a new project is initiated in Microsoft VIiual Studio, you get one . csproj file along with the main solution (. sln) file.

Is sln file necessary?

As far as I'm aware, the SLN is a 100% Visual Studio Tooling concept. You can still create applications, run/compile/publish them without this file. That's how Visual Studio Code does it and that's how you would do it in Sublime/Atom or any other editors.

Can I delete Csproj user file?

It shouldn't hurt anything to delete it other than you will lose any personal settings in the IDE and have to redo them. Show activity on this post. Delete the . user file.


2 Answers

You should commit the .sln and the .csproj, but not the .suo or the .user files.

You can add the following to .gitignore:

#ignore thumbnails created by windows Thumbs.db #Ignore files build by Visual Studio *.obj *.exe *.pdb *.user *.aps *.pch *.vspscc *_i.c *_p.c *.ncb *.suo *.tlb *.tlh *.bak *.cache *.ilk *.log [Bb]in [Dd]ebug*/ *.lib *.sbr obj/ [Rr]elease*/ _ReSharper*/ [Tt]est[Rr]esult* 
like image 106
SLaks Avatar answered Oct 13 '22 08:10

SLaks


SLN (Solution) are the solution files. It stores info about the collection of projects that make up whatever you are developing. They contain projects, source control settings, or any other global level thing.

CSProj(Project file) are the actual code projects (C# Libraries, WCF Services, etc). It stores information at the project level. It wraps all relevant References, Classess, etc..

SUO (solution user options) are user settings files. Completely disposable, you can delete it and the most common thing you will lose are breakpoints.


Push everything except the SUO settings files.

Do not include any bin, debug, obj directory. The only DLLs (or compiled/generated object) you should include are those that are external to your application.

like image 32
Nix Avatar answered Oct 13 '22 06:10

Nix