71

What exactly is the purpose of the 'obj' directory in .NET?

0

2 Answers 2

95

The "obj" folder is used to store temporary object files and other files used in order to create the final binary during the compilation process.

The "bin" folder is the output folder for complete binaries (assemblies).

0
59

In addition to splattne's answer, I believe the reason for having it (and not cleaning it up after the build) is to support incremental compilation. If you've already compiled 100 classes and change one of them, it's much more efficient to just recompile the code for the one changed class and reassemble the exe/dll from a mixture of the new and old code.

Of course, incremental compilation is a lot more complex than just that - it has to keep track of everything so it can detect when it needs to recompile a class even if that class itself hasn't changed. (e.g. if a new overload becomes available in a class - some callers may need to be recompiled.)

4
  • What's the source for the obj files? I ask because I'm having a problem with an Azure Cloud Service project that is packaging the wrong version of System.Runtime.dll. Please see here.
    – Shaul Behr
    Nov 13, 2016 at 13:47
  • @ShaulBehr: Not sure what you mean by "source" here, but I don't think I can shed any light on your problems, I'm afraid.
    – Jon Skeet
    Nov 13, 2016 at 16:30
  • I mean, how does Visual Studio decide which version of a given DLL gets copied into the obj folder? In my case, if the worker role project is referring to v4.3.1 of System.Runtime, why would the Cloud Service project be copying a different version of the DLL into its obj folder?
    – Shaul Behr
    Nov 13, 2016 at 16:36
  • @ShaulBehr: That I don't know, I'm afraid - I haven't done any Azure projects.
    – Jon Skeet
    Nov 13, 2016 at 17:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.