C# .NET 中的“obj”目录是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/233081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 19:11:43  来源:igfitidea点击:

What's the 'obj' directory for in .NET?

c#.net

提问by Andrew Jones

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

.NET 中“obj”目录的目的究竟是什么?

采纳答案by splattne

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

“目标文件”文件夹,用来存储,以便在编译过程中创建最终的二进制使用的临时对象文件和其他文件。

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

“bin”文件夹是完整的二进制文件(组件)的输出文件夹。

回答by Jon Skeet

In addition to splattne's answer, I believe the reasonfor 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.

除了splattne的答案,我相信原因具有它(编译后不清除它)是支持渐进式编译。如果您已经编译了 100 个类并更改了其中的一个,那么只需重新编译一个更改后的类的代码并从新旧代码的混合中重新组装 exe/dll 会更有效率。

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.)

当然,增量编译比这复杂得多——它必须跟踪所有内容,以便它可以检测到何时需要重新编译一个类,即使该类本身没有改变。(例如,如果新的重载在类中可用 - 某些调用者可能需要重新编译。)