为什么C#不允许像Java这样的增量编译? [英] Why doesn't C# allow incremental compilation like Java?

查看:72
本文介绍了为什么C#不允许像Java这样的增量编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么C#不允许像Java这样的增量编译?


具体来说,在Java中我可以单独编译单个.java文件。

结果可以将单个.class文件分组为.jar文件。


在C#中,似乎没有模拟。我必须将所有.cs

文件编译成单个.dll。


这在编译方面有严重的缺点。使用Eclipse,我会更改一个文件,只重新编译该文件。使用Visual Studio,我需要更改文件并且必须手动重新编译,大型项目可能需要10 +

秒(即使我所做的只是添加了一个空间到

评论)。


为什么做出这个设计决定?有没有办法加速

Visual Studio 2005 C#编译?是否有计划在未来版本的Visual Studio中编译背景




谢谢。

Why doesn''t C# allow incremental compilation like Java?

Specifically, in Java I can compile single .java files in isolation.
The resulting individual .class files can be grouped into .jar files.

In C#, there appears to be no analog. I have to compile all my .cs
files into a single .dll.

This has serious drawbacks in terms of compilation. With Eclipse, I
change a file and only that file is re-compiled. With Visual Studio, I
change a file and have to manually re-compile, which may take 10+
seconds for large projects (even if all I did was add a space to a
comment).

Why was this design decision made? And is there any way to speed up
Visual Studio 2005 C# compilation? Are there plans to have background
compilation in future versions of Visual Studio?

Thanks.

推荐答案

这不是真的,真的。您可以编译成单独的netmodules

(使用/ target:module开关),然后使用程序集链接器工具(al.exe)将它们组装成一个程序集

。 br />

你应该能够配置VS.NET 2005来输出一个模块,通过

更改项目文件(具体来说,是csc任务的输入)。 br />

希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


< mw ********@gmail.com在留言中写道

news:11 ******************** @ b75g2000hsg.googlegrou ps .com ...
That''s not true, really. You could compile into individual netmodules
(using the /target:module switch) and then assemble them into an assembly
using the assembly linker tool (al.exe).

You should be able to configure VS.NET 2005 to output a module by
changing the project file (specifically, the inputs to the csc task).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<mw********@gmail.comwrote in message
news:11********************@b75g2000hsg.googlegrou ps.com...

为什么C#不允许像Java这样的增量编译?


具体来说,在Java I中可以单独编译单个.java文件。

生成的单个.class文件可以分组为.jar文件。


在C#中,似乎有没有模拟。我必须将所有.cs

文件编译成单个.dll。


这在编译方面有严重的缺点。使用Eclipse,我会更改一个文件,只重新编译该文件。使用Visual Studio,我需要更改文件并且必须手动重新编译,大型项目可能需要10 +

秒(即使我所做的只是添加了一个空间到

评论)。


为什么做出这个设计决定?有没有办法加速

Visual Studio 2005 C#编译?是否有计划在未来版本的Visual Studio中进行背景

编译?


谢谢。
Why doesn''t C# allow incremental compilation like Java?

Specifically, in Java I can compile single .java files in isolation.
The resulting individual .class files can be grouped into .jar files.

In C#, there appears to be no analog. I have to compile all my .cs
files into a single .dll.

This has serious drawbacks in terms of compilation. With Eclipse, I
change a file and only that file is re-compiled. With Visual Studio, I
change a file and have to manually re-compile, which may take 10+
seconds for large projects (even if all I did was add a space to a
comment).

Why was this design decision made? And is there any way to speed up
Visual Studio 2005 C# compilation? Are there plans to have background
compilation in future versions of Visual Studio?

Thanks.



我已经研究过了,但是在Visual

Studio中它是不可能的(它总是把项目编译成dll')。无论如何,它仍然是
使项目成为最小的编译单位。理想情况下,重新编译所需的时间应该与项目中已更改类的数量成比例。

显然更改

非私有接口会强制更改类的依赖关系重新编译,但是如果我将单个语句添加到单个方法

单个类需要完全相同的编译时间,好像

我已经为项目中的每个类添加了一个语句。

Mark


4月19日晚上10点31分,Nicholas Paldino [.NET / C#MVP]"

< m ... @ spam.guard.caspershouse.comwrote:
I''ve looked into that, but it''s not possible to do within Visual
Studio (it always compiles projects to dll''s). Regardless, it still
makes the project the minimum unit of compilation. It seems like
ideally the time it takes to re-compile should be proportional to the
number of changed classes within a project. Obviously changing the
non-private interface forces the dependencies of a changed class to be
re-compiled, but if I add a single statement to a single method of a
single class it takes exactly the same amount of time to compile as if
I''d added a statement to every class in the project.

Mark

On Apr 19, 10:31 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:

这不是真的,真的。您可以编译单个netmodules

(使用/ target:module开关),然后使用程序集链接器工具(al.exe)将它们组装成一个程序集




您应该能够通过改变项目文件(具体来说,是csc任务的输入)来配置VS.NET 2005以输出模块。


希望这会有所帮助。


-

- Nicholas Paldino [.NET / C#MVP]

- m ... @ spam.guard.caspershouse.com


< mwelsh1 ... @ gmail.comwrote in message


news:11 ******************** @ b75g2000hsg.googlegrou ps.com ...
That''s not true, really. You couldcompileinto individual netmodules
(using the /target:module switch) and then assemble them into an assembly
using the assembly linker tool (al.exe).

You should be able to configure VS.NET 2005 to output a module by
changing the project file (specifically, the inputs to the csc task).

Hope this helps.

--
- Nicholas Paldino [.NET/C#MVP]
- m...@spam.guard.caspershouse.com

<mwelsh1...@gmail.comwrote in message

news:11********************@b75g2000hsg.googlegrou ps.com...

为什么C#allowincrementalcompilation不像Java那样?
Why doesn''t C# allowincrementalcompilation like Java?


具体来说,在Java中,我可以单独编译单个.java文件。

生成的单个.class文件可以分组到.jar文件。
Specifically, in Java I cancompilesingle .java files in isolation.
The resulting individual .class files can be grouped into .jar files.


InC#,似乎没有模拟。我将我的.cs

文件编译成单个.dll。
InC#, there appears to be no analog. I have tocompileall my .cs
files into a single .dll.


这在编译方面有严重的缺点。使用Eclipse,我会更改一个文件,只重新编译该文件。使用Visual Studio,我需要更改文件并且必须手动重新编译,大型项目可能需要10 +

秒(即使我所做的只是添加了一个空间到

评论)。
This has serious drawbacks in terms of compilation. With Eclipse, I
change a file and only that file is re-compiled. With Visual Studio, I
change a file and have to manually re-compile, which may take 10+
seconds for large projects (even if all I did was add a space to a
comment).


为什么做出这个设计决定?有没有办法加速

Visual Studio 2005C#编译?是否有计划在Visual Studio的未来版本中进行背景

编译?
Why was this design decision made? And is there any way to speed up
Visual Studio 2005C#compilation? Are there plans to have background
compilation in future versions of Visual Studio?


谢谢。
Thanks.



mw ********@gmail.com 写道:

我已经研究过了,但它不可能在Visual />
Studio中进行(它总是将项目编译为dll')。
I''ve looked into that, but it''s not possible to do within Visual
Studio (it always compiles projects to dll''s).



VS提供标准功能。


我觉得很难相信构建时间应该是b $ b确实是个问题。


如果你想要最大程度地控制构建,然后使用NAnt。


Arne

VS provides "standard" functionality.

I find it hard to believe that build time should
really be a problem.

If you want maximum control over the build, then use NAnt.

Arne


这篇关于为什么C#不允许像Java这样的增量编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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