为什么又编译时是二进制输出不相等? [英] Why is the binary output not equal when compiling again?

查看:250
本文介绍了为什么又编译时是二进制输出不相等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个构建脚本编译几个C#项目。二进制输出被复制到一个结果文件夹,覆盖这些文件的previous版本,然后添加/致力于颠覆。

I'm using a build script to compile several C# projects. The binary output is copied to a result folder, overwriting the previous version of the files, and then added/committed to subversion.

我注意到编译的二进制输出是不同的,即使没有改变,在所有的源或环境。这怎么可能?是不是二进制结果应该是相同的输入正好等于?

I noticed that the binary output of the compilation are different even when there was no change to the source or environment at all. How is this possible? Isn't the binary result supposed to be exactly equal for the same input?

我不是故意使用任何一种特殊的时间戳的任何地方,但该编译器(微软,一个包含在.NET 4.0中)可能添加时间戳本身?

I'm not intentionally using any kind of special timestamps anywhere, but does the compiler (Microsoft, the one included in .NET 4.0) possibly add timestamps itself?

我问的是我犯的输出到颠覆的原因,由于我们的方式生成服务器的工作原理选中的改变引发重建,引起了再次修改的二进制文件进行检查在转了一圈

The reason I'm asking is I'm committing the output to subversion, and due to the way our build server works the checked in changes trigger a rebuild, causing the once again modified binary files to be checked in in a circle.

推荐答案

更​​新:<一href="http://blogs.msdn.com/b/ericlippert/archive/2012/05/31/past-performance-is-no-guarantee-of-future-results.aspx">This问题是,我的博客在2012年5月的主题。感谢伟大的问题!

UPDATE: This question was the subject of my blog in May 2012. Thanks for the great question!

这怎么可能呢?

变得非常容易。

不是二进制结果应该是相同的输入?

Isn't the binary result supposed to be exactly equal for the same input?

绝对不是。与此相反的是真实的。 运行编译器每当你应该得到不同的结果。,否则你怎么会知道,你会重新编译?

Absolutely not. The opposite is true. Every time you run the compiler you should get a different output. Otherwise how could you know that you'd recompiled?

C#编译器嵌入一个新生成的GUID在每次编译的程序集,从而保证没有任何两个汇编产生相同的结果。

The C# compiler embeds a freshly generated GUID in an assembly on every compilation, thereby guaranteeing that no two compilations produce exactly the same result.

此外 - 即使没有GUID,编译器不保证任何两个相同的合辑将产生相同的结果。

Moreover -- even without the GUID, the compiler makes no guarantees whatsoever that two "identical" compilations will produce the same results.

在特别是,在其中的元数据表被填充的顺序是高度依赖于文件系统的细节; C#编译器开始在将文件被赋予的顺序生成的元数据,并且可以由多种因素来微妙地改变。

In particular, the order in which the metadata tables are populated is highly dependent on details of the file system; the C# compiler starts generating metadata in the order in which the files are given to it, and that can be subtly changed by a variety of factors.

由于我们的方式生成服务器的工作原理选中的改变引发重建,引起了再次修改的二进制文件了一圈检查在

due to the way our build server works the checked in changes trigger a rebuild, causing the once again modified binary files to be checked in in a circle.

我想解决这个问题,如果我是你。

I'd fix that if I were you.

这篇关于为什么又编译时是二进制输出不相等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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