AssemblyVersion vs AssemblyFileVersion

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值