来自不同计算机上相同C#源代码的可重复构建 [英] Repeatable builds from same C# source code on different machines

查看:106
本文介绍了来自不同计算机上相同C#源代码的可重复构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一种足够聪明的工具,以编程方式检查由在不同时间在两个单独的机器上编译的相同C#代码生成的发行版二进制文件,并得出结论,该代码是相同的,并且能够提取任何代码更改,如果用于生成这些二进制文件的c#代码中提供的信息.

I am trying to produce a tool which is smart enough to programmtically examine release version binaries produced by identical C# code compiled on two seperate machinces at different times and conclude that the code was identical while being able to pick up any code changes if present in the c# code used to produce these binaries.

我尝试了多种方法,但是为了简短起见,我将坚持最新的尝试. 我在二进制文件上使用/text选项运行ildasm,并替换文本中匿名字段等的GUID,但是当二进制文件来自其他pc时,我发现由ILDASM/text选项生成的文本已重新排序.源自相同代码但在不同计算机上通过相同设置编译的二进制文件也似乎进行了重新排序.任何建议如何可能能够控制这种IL的重新排序,将不胜感激?

I have tried using a number of approaches but in order to keep this short i'll just stick to the latest attempt. I run ildasm with the /text option on the binaries and replace the GUIDs for anonymous fields etc in text, but when the binaries come from different pcs i find that the text produced by ILDASM /text option is reordered. The binaries originating from the same code but compiled by same setup on different machines also appear heavily reordered. Any suggestion how one may be able to control this reordering of IL would be much appreciated ?

欢呼

PS:也欢迎任何可靠地实现此目标的替代策略.

PS: Any alternative strategies of reliably accomplishing this are also most welcome.

推荐答案

我发现,可以通过设置处理器对编译的亲和力来实现根据埃里克·利珀特(Eric Lippert)在他的帖子中提到的客户最终解决的解决方案.处理到01.此后,所生成的可执行文件/dll与som mvid和guid几乎完全相同.在文本模式下在这些二进制文件上运行ILDASM并构建一个简单的散列工具以删除这些随机内容提供了这样的解决方案.我只是为了完成本文档并提供帮助,以帮助可能会遇到此问题的其他人.

I found that a solution in accordance to what Eric Lippert's mentioned in his post what his client ended up settling for can be reached by setting the processor affinity for the compilation process to 01. After this the executables/ dlls produced are almost identical in excpetion to som mvid and guids used. Running ILDASM on these binaries with the text mode and building a simple hashing tool to strip away this random stuff provides such a solution. I am just providing this for the sake of completion and to help others who may face this problem.

这篇关于来自不同计算机上相同C#源代码的可重复构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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