views:

43

answers:

2

I am using Google Code to host my C# project. It has a solution with one class library and one test project. I am using Visual Studio 2010.

The client I am using is TortoiseHG.

In Windows Explorer, first I cloned an empty folder and got the .hg files inside of it so that it is associated with my hosted code. Now, I created a new C# project and copies all files inside my root source code controlled folder. I will work on it hereafter.

When committing, there are lots of files and folders inside my solution folder and not all of them are code. Usually I just build and take out the EXE or DLL and never really bothered with other stuff. Now I feel not all files and folders are important for source code control.

I am really new to source control.

Which files/folders should go into source control, apart from the actual code files themselves?

+2  A: 

Good question! The rule of thumb that I use is the following:

  1. Check in all files in the folder to have a complete tree
  2. Work a bit with this and notice the Pending Checkins
  3. The files that are pending but you haven't touched are Visual Studio files that are updated while you work to keep settings of the project.
  4. Careful now: the *.sln, *.csproj and other project files will change as well, these must be checked in.
  5. Other files, esp. the ones that "look" binary (in the obj dir and the *.suo file for instance) can be marked for the exclusion list.

You may decide to include the built versions of the DLL or EXE, but this is not necessary, as anybody loading your project can built it. Now, the next step is:

  • After you worked a bit and think you've created a stable file list, get the whole project to another location and compile immediately. Does it work? Does it miss files?

If this last step works (and you should check it on a regular basis), you have a solid basis for your files.

Note: some tools support Visual Studio from within and know what files should or should not be included, i.e., for SVN I know that VisualSVN does a rather good job of skipping the unneeded files.


Two more rule of thumbs (oh, three, actually):

  • Be specific in what you exclude, be liberal in what you include: it is better to include too much than too little;
  • A few extensions that can safely be excluded: *.user (root of any project), \obj\** (all under the temporary obj-folder), *.vspscc and *.vssscc (root of project), *.suo and depending on your preferences: \bin\**.
  • Oh, and for website projects, these may contain or add a PrecompiledWeb directory to your solution, which you really don't want to check in: exclude all here.

EDIT: this question on SO has a very extensive list of files to ignore of Visual Studio.

Abel
So basically I should follow a somewhat informed trial and error method till I get the proper set in. All check-ins before that might have something extra or miss something. Did I get you correct?
Senthil
@Senthil: that's what I basically suggest, yes, but have a look at my update, that should get you started in the right direction. Also note: some projects require auxiliary files, addins, extensions or special libraries. I tend to include all these in one solution (and physical) folder, to be certain that everything is together, with a small instruction file to install extensions/addins.
Abel
Yes, thank you for mentioning those specific files/folders :)
Senthil
+1  A: 

To give a more concise version of @Abel's answer, you can leave out the bin and obj folders and the .suo file. Everything in bin and obj will get recreated when it's built, and .suo is user settings for the project which aren't needed by anyone else.

Grant Crofton
+1 Thats really short and to the point. Thank you :)
Senthil
@Grant: thanks for summarizing my rather extensive answer :)
Abel