什么是“obj”我在创建C#项目时使用的文件夹? [英] What is "obj" folder used for when I created a C# project?

查看:161
本文介绍了什么是“obj”我在创建C#项目时使用的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,当我使用VS创建ac #Project时,在Project文件中,它总是创建一些文件夹和文件,(调试前)



文件夹:

bin

obj

属性




文件:

.cs文件

Visual C#项目文件与项目名称相同。




我想知道:

1,这个 obj 文件夹是什么?其中有一个x86文件夹,x86文件夹里面有一个调试。



2,什么是 Visual C#项目文件意思是(有相同的)项目名称。



谢谢,任何链接都将不胜感激,



ChelseaJCole

解决方案

此目录是构建系统用于放置用于构建的所有中间文件的唯一目录。您可以随时删除此目录,或尝试执行此操作。由于文件都是中间文件,因此您不会冒任何风险。但是,由于构建通常是 incremental ,因此构建的时间可能会增加,因为有些工作会再次完成。重要的是,删除此目录是完全清理项目的方法之一。



现在,因为文件是中间的,所以你不需要看进入这个目录。好吧,差不多。有时,这有助于了解一些事情是如何工作的。一个例子是:WPF项目生成一些公共代码并使用生成的代码进行编译,因此它被放置在obj子目录中。这包括 Main 方法和其他一些东西。在许多情况下,您只需编写代码即可自定义此代码。您可以在obj目录中找到生成的代码,而不是阅读文档,看看它应该如何编写。得到了提示?



现在,关于项目文件的问题要复杂得多;我很难在一篇短文中回答这个问题。这是一个非常先进的项目文件标准,用于通过MSBuild.exe工作。

您不仅可以在Visual Studio中使用它,还可以在许多系统上使用它(Linux,Mac OS X)使用Mono,您可以开发自己的构建步骤(任务),通过开发专门设计的构建程序集,集成任何自定义工具,第三方或您自己的编译器,用于不同语言(不仅仅是针对.NET的那些)以及更多。



最重要的是,您可以在没有Visual Studio的情况下构建任何项目或解决方案。 MSBuild,以及C#和VB.NET编译器都是免费提供的(可再发行的).NET Framework。您只需要执行 MSBuild< parameters> ...



请参阅:

http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/ vstudio / ms164311.aspx [ ^ ]。



文档的第一个分支描述了编程接口和项目文件开发的规则,第二个 - 描述了命令行参数只是MSBuild.exe应用程序。学习第一个可能需要相当大的努力,但如果您需要定制高级产品,您可以获得令人惊讶的整洁和高度自动化的结果。



< br $> b $ b

请看看我过去的答案;其中一部分与主题相关:如何在VB Web应用程序中使用cs类 [ ^ ]。



祝你好运,

-SA


这应该有帮助,



http://bit.ly/YRlb8K [ ^ ]

Hello, When i using VS to create a c# Project, in the Project file, it always create some folders and files,(Before Debug)

Folders:
bin
obj
Properties


Files:
.cs files
A Visual C# Project file has the same name with the Project.


I would like to know:
1, What is this "obj" folder? There is a x86 folder in it and a debug inside x86 folder.

2,What is Visual C# Project file mean (has the same name with the Project).

Thanks, any links will be appreciated,

ChelseaJCole

解决方案

This directory is the only directory use by the build system to place all the intermediate files used for the build. You can remove this directory at any time, or try to do it. As the files are all intermediate, you don't risk to loose anything. However, as the build is usually incremental, the time for build may increase, as some work will be done again. Importantly, deleting of this directory is one of the ways to completely clean-up the project.

Now, as the files are intermediate, you don't need to look into this directory. Well, almost. Sometimes, this is useful to learn how some things work. One example is this: WPF project generates some common code and compiles with that generated code, so it is placed in the "obj" sub-directory. That includes the Main method and some other stuff. In a number of cases, you need to make this code custom by just writing it. Instead of reading the documentation, you can simply find the generated code in "obj" directory and see how it should be written. Got the hint?

Now, the problem about the project file is much more complex; I hardly could answer it in one short post. This is a really advanced standard of project files used to work through MSBuild.exe.
Not only you can use it with Visual Studio, but you can use it on many systems (Linux, Mac OS X) with Mono, you can develop your own build steps ("Tasks") through development of specially designed build assemblies, integrate any custom tools, 3rd-party or your own compilers for different languages (not only those targeting .NET) and a lot more.

Most importantly, you can build any project or solution without Visual Studio. MSBuild, as well as C# and VB.NET compilers comes for free with the (redistributable) .NET Framework. You just need to execute MSBuild <parameters>....

Please see:
http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx[^],
http://msdn.microsoft.com/en-us/library/vstudio/ms164311.aspx[^].

First branch of documentation describes programming interface and the rules for the development of the project file, the second one — describes the command-line parameters of just the the MSBuild.exe application. Learning the first one may need considerable effort, but if you need custom of just advanced product build, you can get amazingly neat and highly automated results.

[EDIT]

Please also take a look at my past answer; some part of it is related to the topic: How to use cs class in a VB web application[^].

Good luck,
—SA


This should help,

http://bit.ly/YRlb8K[^]


这篇关于什么是“obj”我在创建C#项目时使用的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆