Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I not check bin and obj folders in, in SVN

Tags:

This seems to be very basic question but I'm eager to know the answer. I'm using Subversion (SVN) for source control and I've been checking in all the files, but the client asked me to create a rule in SVN to avoid checking in the bin and obj folders.
Why should I not check the bin and obj folders in?

The client also asked me to keep the solution file outside the repository folder. Why is that?

like image 894
VJAI Avatar asked Aug 01 '11 09:08

VJAI


People also ask

Can I delete bin and obj folders?

Delete bin and obj foldersThe bin and obj folders are usually safe to delete since they are automatically generated when the solution/project is being build by Visual Studio/MSBuild. This feature is off by default, but can easily be enabled in the settings.

What is the difference between obj and bin folders?

In summary, in “obj” folder, we have compiled files for each source code file and in “bin” folder, we have a single unit which links all individually compiled code files.

How do I ignore bin and obj folder in SVN?

The text box “Global ignore pattern” defines what patterns you want to exclude; in my case I wanted to remove bin and obj folders, and ReSharper related files, which typically contain _ReSharper, so I added bin obj _ReSharper to the list of patterns. Et voila!

How do I ignore obj and bin folder in git?

While the sdk create the bin and obj folder, if it create a . gitignore with * as content, git will automatically ignore the content of this folder.


2 Answers

You should not add any temporary files to SVN, they're temporary. The entire obj directory consists of files that are created during the build process and are then discarded. (sure, they stay on disk because some are re-used, like a cache, when the source files don't change but that's the only reason they're not deleted after each build).

the bin directory is a slightly different matter. It is ok to add binary files to SVN, you probably already do it for icon and image files already. Some people add the built binaries as well, that's a decision that depends on your configuration management processes, there's no 'wrong' answer. However, sometimes your bin directory can become filled with other files that you do not want to add. If you're building .net apps, you'll get a load of dependant dlls copied to the bin directory that are not strictly part of your project. Adding those will just bloat your repository for no benefit. Similarly, there are supporting binaries in bin such as .pdb debug symbol files. These aren't really needed either.

For the solution file, I'm not sure of the question but if its not to be checked in it'll be because a .sln file is just a "wrapper" for one or more project files. Its not strictly needed to build a visual studio project as a new one will be created as needed. I guess your users might create their own .sln files with different groups of projects in them, making each one different to each user. That would be a reason to prevent checkin, so each user would not overwrite each other's custom files (though there are ways for a user to prevent modification of a file that is stored in svn).

So it sounds like your configuration strategy doesn't involve adding any binaries to svn. In which case its a very good idea to prevent this from accidentally happening with a pre-commit hook. I would also recommend adding these exclusions to the client-side global-ignores to assist your users from ever trying to add these files in the first place.

like image 198
gbjbaanb Avatar answered Sep 17 '22 11:09

gbjbaanb


"should not" doesn't apply to everyone. But generally:

1) Don't checkin binaries that can be generated from code.

2) SVN is a source code versioning system, and not designed with binaries in mind. Yes, SVN and other VCSs can handle binaries, but it is not their intended purpose, especially after point 1)

3) Since these are generated by your source code, they will change a lot and are not like the libraries that rarely change. Frequently changing binaries tax the VCS as any VCS cannot properly handle binaries and you tend to store more with every change to the binaries as the diffing ( delta ) is not as efficient as with source code.

Coming to the solution ( .sln ) files, it is ideal to checkin them to the repository, though not absolutely necessary. But most, if not all, .Net project are Visual Studio based and even for build purposes, having a .sln file makes the job much easier as you can call msbuild on the sln file rather than the csproj ( or other project ) files. You get other advantages like proper dependency compile, parallel compile etc.

like image 23
manojlds Avatar answered Sep 19 '22 11:09

manojlds