.NET 程序集名称是否应该包含版本号?

发布于 2024-07-09 21:48:09 字数 129 浏览 3 评论 0原文

目前,我们内部正在激烈争论实际的.NET 程序集名称是否应包含代码的版本号(例如CodeName02.exe 或CompanyName.CodeName02.dll)。 有谁知道像 Microsoft 这样的权威来源可以提供有关此问题的指导?

We currently have a heated internal debate as to whether the actual .NET assembly name should include the code's version number (e.g. CodeName02.exe or CompanyName.CodeName02.dll). Does anyone know of an authoritative source, like Microsoft, that provides guidance on this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

喜你已久 2024-07-16 21:48:09

这就是 Properties/AssemblyInfo.cs 文件的用途。

该文件中有两个版本,即文件版本和程序集版本:

[assembly: AssemblyVersion("1.1.0.256"]
[assembly: AssemblyFileVersion("1.1.0.256")]

设置这些版本后,您可以使用它们来跟踪二进制文件的版本。 通过右键单击->属性,可以在资源管理器中轻松查看它。

Microsoft 应用程序(和操作系统)中包含的 dll 或 exe 名称均未使用该约定。

其他系统将使用这些数字来解决依赖关系并验证版本。 例如,MSI 系统将根据版本属性更新二进制文件。

This is what the Properties/AssemblyInfo.cs file is for.

There are two versions within that file, the file version and the assembly version:

[assembly: AssemblyVersion("1.1.0.256"]
[assembly: AssemblyFileVersion("1.1.0.256")]

Once these are set you can use them to track the versions of you binaries. It is easily viewed in explorer with right click->properties.

None of the dll or exe names included in Microsoft's applications (and OS) use that convention.

Other systems will use these numbers to resolve dependencies and verify the version. For example the MSI system will update binaries based on the version properties.

澜川若宁 2024-07-16 21:48:09

框架设计指南,作者:Krzysztof Cwalina 和 Microsoft 的 Brad Abrams建议程序集命名,就像

<Company>.<Component>.dll

我进一步支持这一点(不使用版本号),因为 GAC 和 dll 文件属性将显示版本。

Framework Design Guidelines by Krzysztof Cwalina and Brad Abrams of Microsoft suggests assembly naming like

<Company>.<Component>.dll

I further support this (NOT using version #) because the GAC and dll file properties will show the version.

浊酒尽余欢 2024-07-16 21:48:09

我知道 DevExpress 网站 使用版本指示符作为其程序集名称的一部分,例如 XtraEditors8.2.dll。 我想原因是您希望能够在同一目录中拥有多个版本的程序集。 例如,我们有大约 15 个智能客户端,它们作为同一 shell/客户端的一部分进行分发。 每个智能客户端可以有不同版本的 DevExpress 控件,因此我们需要能够将 XtraEditors7.1.dll 和 XtraEditors8.2 存在于同一目录中。

我想说,如果您有一些公共库,它们是可重用模块的依赖项,并且可以存在于多个版本 1.0、1.1、1.2 等中,那么可以在名称中包含版本号以避免冲突,这将是一个有效的论点。 鉴于公共库不在 GAC 中。

I know DevExpress website use version indicators as part of their assembly names such as XtraEditors8.2.dll. I guess the reason is that you want to be able to have multiple versions of the assembly located in the same directory. For example we have about 15 smartclients that are distributed as part of the same shell/client. Each smartclient can have a different version of DevExpress controls and therefore we need to be able to have XtraEditors7.1.dll and XtraEditors8.2 existing in the same directory.

I would say that if you have common libraries that are dependencies of reusable modules and can exist in multiple versions 1.0, 1.1, 1.2 etc. then it would be a valid argument that version numbers could be included in the name to avoid collisions. Given that the common libs are not living in the GAC.

硪扪都還晓 2024-07-16 21:48:09

我不知道任何权威的信息,但在我看来,使用一致的名称会简化从安装脚本到文档的过程的一切。 鉴于可以将版本作为元数据存储在文件上,我不知道为什么文件名中需要它。 为什么要让自己陷入必须考虑不同名称文件的麻烦呢?

I'm not aware of anything authoritative, but it would seem to me that using a consistent name would simplify everything from the process of installation scripts to documentation. Given that one can store the version as metadata on the file, I don't know why it would be needed in the filename. Why set yourself up for the hassle of having to account for differently-named files?

护你周全 2024-07-16 21:48:09

只需查看 .NET 框架或任何其他微软产品即可。 将版本号作为程序集名称的一部分听起来是个坏主意。

在程序集的元数据部分中有一个位置可以存放此信息(以及其他信息)。 (AssemblyInfo.cs)

可以在 Windows 资源管理器中查看此信息(属性对话框、状态栏、工具提示 - 它们都显示此信息)。

just look at the .NET framework or any other microsoft product for that matter. putting a version number as part of the assembly name sounds like a bad idea.

There is a place for this (and other information) in the assembly's meta-data section. (AssemblyInfo.cs)

This information can be view in Windows Explorer (properties dialog,status bar, tooltip - they all show this information).

孤云独去闲 2024-07-16 21:48:09

我认为将版本号放在 DLL 文件名中的主要思想是从DLL Hell带来的,其中具有多个版本的 DLL,所有版本都具有相同的名称会导致问题(即哪个实际版本)您有 DLL 的文件吗?它是否具有所需的功能,等等)。

与更传统的 C/C++ DLL 文件相比,.NET Framework 处理依赖关系的方式完全不同,GAC 中可能存在库的多个版本,主要是因为 GAC 是链接到其他文件的“假”文件夹在文件系统上,除了能够将程序集包含在可执行文件安装中(同一文件夹部署等)。

I think the main idea of putting a version number in the filename of a DLL is brought over from DLL Hell, where having multiple versions of the DLL, all with the same name caused problems (i.e. which actual version of a DLL do you have and does it have the required functions, etc).

The .NET Framework handles dependencies completely different compared to the C/C++ DLL files that are more traditional, it is possible to have multiple versions of a library in the GAC, mainly because the GAC is a 'fake' folder that links to other files on the filesystem, in addition to being able to have the assemblies included with your executable install (same folder deploy, etc).

长安忆 2024-07-16 21:48:09

版本信息可以包含在 assemblyInfo 文件中,然后可以通过反射等方式查询。

一些供应商在名称中包含版本号,以便更容易一眼看出它是什么。 Microsoft dll 名称在框架目录中不包含版本号。

The version information can be contained in assemblyInfo file and can then be queried via reflection etc.

Some vendors include the version number in the name to make it easier to see at a glance what it is. The Microsoft dll names dont contain a version number in framework directory.

娇俏 2024-07-16 21:48:09

既然版本可以设置为属性,这不是半多余的吗?

我还冒昧地建议微软没有一个标准,快速浏览一下它们的 DLL 名称:user32.dll、tcpmon.dll、winsock.dll 等。

Since the version can be set as a property isn't this semi redundant?

I'd also go on a limb and suggest MS doesn't have a standard given a quick look at their DLL names: user32.dll, tcpmon.dll, winsock.dll, etc.

So要识趣 2024-07-16 21:48:09

Microsoft 使用后缀 32 来表示 32 位 DLL 版本,以便这些 DLL 可以与现有的 16 位 DLL 文件共存。

Microsoft used a suffix of 32 to denote 32 bit DLL versions so that those DLL's could coexist with the existing 16 bit DLL files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文