【问题标题】:Get exactly the same assembly when compiling in .NET [duplicate]在.NET中编译时获得完全相同的程序集[重复]
【发布时间】:2011-02-02 14:56:48
【问题描述】:

可能重复:
Determine whether .NET assemblies were built from the same source

我想比较 .NET 中的程序集以检查是否有任何更改。浏览网络后,我发现编译器更改了构建日期、版本修订(如果未明确指定)和许多其他内容。 msbuild 中是否有一个选项可以通过两个不同的构建获得完全相同的结果?

【问题讨论】:

  • 你想比较什么?您总是可以使用反射来对成员体进行二元比较。
  • 你能在比较中忽略这些因素吗?可能有点复杂,但绝对是更好的做法。
  • 感谢您向我推荐这个问题,使用 ildasm 可能是一种可能的方法。

标签: .net msbuild compilation .net-assembly


【解决方案1】:

Visual Studio 项目有一个名为 AssemblyInfo 的文件,其中包含有关程序集的元数据。

你可以在那里设置版本信息。

这是AssemblyInfo 文件中的一个部分的示例:

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

【讨论】:

  • 不幸的是,MVID(模块版本标识符)值也在不断变化,无法控制。
  • 没错,MVID 是我试图忽略的更改之一。
【解决方案2】:

在忽略特定令牌的同时使用 ILDASM 是一种可能的方法。感谢chibacity。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-03
    • 1970-01-01
    • 2014-10-15
    相关资源
    最近更新 更多