Summary
AssemblyInfo.cs provides two attributes to set two different types of versions. This tip shows how to use those two attributes.
Microsoft .NET framework provides opportunity to set two different types of version numbers to each assembly.
AssemblyVersion
It's the version number used by framework during build and at runtime to locate, link, and load the assemblies. When you add reference to any assembly in your project, it's this version number that gets embedded. At runtime, Common Language Runtime (CLR) looks for assembly with this version number to load. But remember this version is used along with name, public key token and culture information only if the assemblies are strong-named signed. If assemblies aren't strong-named signed, only file names are used for loading.
AssemblyFileVersion
It's the version number given to file as in file system. It's displayed by Windows Explorer, and never used by .NET framework or runtime for referencing.
Attributes in AssemblyInfo.cs
Suppose you're building a framework assembly for your project that is used by lot of developers while building the application assemblies. If you release new version of assembly frequently, say once every day, and if assemblies are strong named, Developers will have to change the reference every time you release new assembly. It can be cumbersome and may lead to wrong references also. A better option in such closed group and volatile scenarios would be to fix the AssemblyVersion and change only the AssemblyFileVersion. Use the assembly file version number to communicate the latest release of assembly. In this case, developers won't have to change the references and they can overwrite the assembly in reference path. In central or final release builds it makes more sense to change the AssemblyVersion and most keep the AssemblyFileVersion same as assembly version.
// Version information for an assembly consists of the following four values:
// Major Version
// Minor Version
// Build Number
// Revision
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
摘自:
Use AssemblyVersion and AssemblyFileVersion - Visual Studio | Microsoft Docs
本文介绍了如何在软件开发中有效使用AssemblyVersion和AssemblyFileVersion属性,避免频繁更新带来的引用问题。重点讲解了在不同场景下设置这两个版本号的重要性,以及如何在团队协作中简化版本更新流程。
1021

被折叠的 条评论
为什么被折叠?



