Which files/folders in a Visual Studio 2010 C# Solution should go into Mercurial DVCS?
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 ne开发者_开发问答w to source control.
Which files/folders should go into source control, apart from the actual code files themselves?
Good question! The rule of thumb that I use is the following:
- Check in all files in the folder to have a complete tree
- Work a bit with this and notice the Pending Checkins
- 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.
- Careful now: the
*.sln
,*.csproj
and other project files will change as well, these must be checked in. - 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 temporaryobj
-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.
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.
精彩评论