What are the obj and bin folders (created by Visua

2019-01-02 22:38发布

I created a new project in Visual Studio 2010 and noticed that there are now two new folders named obj and bin in my project directory.

A similar pair of folders are created when building and debugging - what are these folders for?

4条回答
Rolldiameter
2楼-- · 2019-01-02 22:58

The obj directory is for intermediate object files and other transient data files that are generated by the compiler or build system during a build. The bin directory is the directory that final output binaries (and any dependencies or other deployable files) will be written to.

You can change the actual directories used for both purposes within the project settings, if you like.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-02 23:01

One interesting fact about the obj directory: If you have publishing set up in a web project, the files that will be published are staged to obj\Release\Package\PackageTmp. If you want to publish the files yourself rather than use the integrated VS feature, you can grab the files that you actually need to deploy here, rather than pick through all the digital debris in the bin directory.

查看更多
forever°为你锁心
4楼-- · 2019-01-02 23:08

I would encourage you to see this youtube video which demonstrates the difference between C# bin and obj folders and also explains how we get benefit of incremental / conditional compilation.

C# compilation is a two step process , see the below diagram for more details :-

  1. Compiling :- In compiling phase individual C# code files are compiled in to individual compiled units. These individual compiled code files goes in the OBJ directory.
  2. Linking :- In linking phase these individual compiled code files are linked to create single unit DLL and EXE. This goes in the BIN directory.

C# bin vs obj folders

If you compare both bin and obj directory you will find more number of files in "obj" directory as it has individual compiled code files while "bin" has a single unit.

bin vs obj

查看更多
聊天终结者
5楼-- · 2019-01-02 23:11

The obj folder holds object, or intermediate, files, which are compiled binary files that haven't been linked yet. They're essentially fragments that will be combined to produce the final executable. The compiler generates one object file for each source file, and those files are placed into the obj folder.

The bin folder holds binary files, which are the actual executable code for your application or library.

Each of these folders are further subdivided into Debug and Release folders, which simply correspond to the project's build configurations. The two types of files discussed above are placed into the appropriate folder, depending on which type of build you perform. This makes it easy for you to determine which executables are built with debugging symbols, and which were built with optimizations enabled and ready for release.

Note that you can change where Visual Studio outputs your executable files during a compile in your project's Properties. You can also change the names and selected options for your build configurations.

查看更多
登录 后发表回答