MSIL - 我可以找到用于构建/编译 .NET 程序集的 Visual Studio 版本吗? [英] MSIL - Can I find the Visual Studio version that was used to build/compile a .NET assembly?

查看:32
本文介绍了MSIL - 我可以找到用于构建/编译 .NET 程序集的 Visual Studio 版本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于构建程序集的程序名称是否可以写入程序集中的 MSIL 代码中的任何位置?

Is the program name that was used to build the assembly written into the assembly available anywhere in the MSIL code?

推荐答案

Visual Studio 不构建任何东西 - Visual Studio 使用 MSBuild 进行构建1:

Visual Studio doesn't build anything - Visual Studio uses MSBuild to do its building1:

Visual Studio 托管 MSBuild 以加载和构建托管项目.

Visual Studio hosts MSBuild to load and build managed projects.

事实上,您可以通过下载 Microsoft 构建工具:

In fact you can build MSIL code without Visual Studio by downloading Microsoft Build Tools:

如果您的计算机上没有安装 Visual Studio,您可以使用 Build Tools 2013 来构建托管应用程序.此下载中还包含 Visual Basic 和 C# 编译器.(在早期版本中,这些工具包含在独立的 .NET Framework 中.)

If you don't have Visual Studio installed on your computer, you can use Build Tools 2013 to build managed applications. The Visual Basic and C# compilers are also included in this download. (In earlier versions, these tools were included in the stand-alone .NET Framework.)

任何编译器满足ECMA 335 标准可以编译有效的公共语言基础结构 (CLI) 应用程序 - Mono C# 编译器就是其中之一这样的例子.

Any compiler which satisfies the ECMA 335 standard can compile valid Common Language Infrastructure (CLI) applications - the Mono C# compiler is one such example.

换句话说,我认为不可能从程序集中获取有关 Visual Studio 版本的信息.

In other words, I don't think it's possible to obtain information about the Visual Studio version from the assembly.

除非 Visual Studio 将一些额外的元数据添加到程序集中(我不认为是),否则要找出哪个版本的 Visual Studio 构建了特定程序集,您必须执行一些操作,例如将您自己的自定义属性添加到程序集中,然后您可以使用反射来检索这些属性.

Unless some additional metadata is added to the assembly by Visual Studio (I don't think it is), to find out what version of Visual Studio built a specific assembly, you'd have to do something like adding your own custom attributes to the assembly, which you could then use reflection to retrieve.

显然,您可以根据程序集所针对的 .NET 版本(例如,Visual Studio 2012 是第一个支持 .NET 4.5 的版本)排除早期版本的 Visual Studio.

Obviously, you can rule out earlier versions of Visual Studio based on the .NET version that the assembly targets (e.g. Visual Studio 2012 was the first to support .NET 4.5).

此表是根据 Visual Studio 的 维基百科文章编译的:

This table is compiled from the Wikipedia article for Visual Studio:

.NET   Min Visual
       Studio version

1.0    2002 (7.0)
1.1    2003 (7.1)
2.0    2005 (8.0)
3.0    2005 (8.0)
3.5    2008 (9.0)
4.0    2010 (10.0)
4.5    2012 (11.0)
4.5.1  2012 (11.0)
4.5.2  2012 (11.0)
4.6    2015 (14.0)

1 默认情况下,Visual Studio 2015 及更高版本使用新的 Roslyn 编译器编译.

1 Visual Studio 2015 and above, by default, uses the new Roslyn compiler to compile.

这篇关于MSIL - 我可以找到用于构建/编译 .NET 程序集的 Visual Studio 版本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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