user2202911
user2202911

Reputation: 3014

Are all files within a C# Project necessary to put under version control?

So I made the decision to learn C#. I downloaded Visual studio and for my first project I just wanted to make a simple Hello world application and put it under source control. I did it but there are a lot of non-source code files that are automatically generated.

For a simple "Hello world" app files include: helloworld.vshost, helloworld.vshost.exe, helloworld.vshost.exe.manifest, helloworld.exe, all the debug files, etc.

Just to make a "Hello world" program. Should only the .cs files be under version control or all these random files as well

Upvotes: 2

Views: 896

Answers (2)

Avner Shahar-Kashtan
Avner Shahar-Kashtan

Reputation: 14700

Not everything under the project folder is a part of the project.

Looking in Visual Studio, in the Solution Explorer, you can see the files that are actually part of the project. In the folder, though, you have the bin and obj folders, which contain temporary and output files. You can also find any number of old files, remains, copied files - all of which aren't compiled and don't find their way to the final product.

Some languages or IDEs look at the folder content as part of the project. Visual Studio manages it internally, in the .CSPROJ files.

So, to answer your question, the files that should be part of source control are the .cs files, .csproj files, .sln, .config and other files that are compiled or part of the project content - scripts, images and so on. The best way not to miss anything, on one hand, and not to add extraneous files is to use a Visual Studio source-control plugin, and do the check-in/check-out operations within VS.

Upvotes: 1

Oded
Oded

Reputation: 498914

None of the *.vshost.* files are needed - these are all used for Visual Studio debugger processes.

You shouldn't put any artefacts produced during compilation into source control either - this includes the .exe file and anything under bin, debug and release.

There are other files that are supposed to be user settings (such as .sua).

You would need the solution file (.sln), project file/s (.csproj), configuration files (.config) and of course any source files, including content (such as images, scripts and whatever else is needed by your executable that is not embedded in it).

See this related Stack Overflow question:

.gitignore for Visual Studio Projects and Solutions

One of the answers points to this github gitignore file for Visual Studio.

Upvotes: 7

Related Questions