What is the AssemblyFileVersion used for in C#?
Asked Answered
M

5

11

In the assemblyInfo.cs I have AssemblyVersion and AssemblyFileVersion.

Normally I just increment the AssemblyVersion like this. 1st digit: Major change 2nd digit: Minor change 3rd digit: bug fixes 4rd digit: Subversion revision number

However, I am wondering what is the AssemblyFileVersion for, and when do I need to increment. Should it be the same as the assemblyVersion?

Should I just comment it out, if I am not using it?

Many thanks for any advice,

Machicolation answered 20/8, 2009 at 4:40 Comment(0)
S
15

AssemblyVersion is used by the .NET class loader and identifies the .NET version of the assembly. AssemblyFileVersion represents the File Version contained in a standard VERSION_INFO block of a Windows PE file...in other words, it represents the file version as seen in the file properties dialog.

If you omit the AssemblyFileVersion, the compiler will default it to be the same as the AssemblyVersion.

Swabber answered 20/8, 2009 at 4:42 Comment(5)
I am not using it. So perfectly safe just to comment it out?Machicolation
It wont break your build. From a maintenance point of view it is good to be able to identify the file version of your assembly (eg to map a bug with a version).Baton
It can also help prevent dependency issues at run-time, as your project wont build if a dependency has the incorrect file version.Baton
@robUK: Yes, you can comment it out. The compiler will then take care of putting it in the VERSION_INFO block for you with the same value as what is in AssemblyVersion.Swabber
@Russell: From a maintenance point of view, the file version can be helpful but since it will default to the assembly version if not provided you are still able to identify the version. As far as the dependency issues, this is based on assembly version, not file version.Swabber
M
5

Generally the file version is more precise than the assembly version. Per example: System.Windows.Form.dll - Assembly Version: 2.0.0.0, File Version: 2.0.50727.3053.

The assembly version is an important information when it is time to load an assembly.

So, if you find a small bug in one of you referenced assembly. You fix the bug, update the file version but you keep the same assembly version. The advantage: you dont have to relink your references to this assembly to the new version and with the file version you can know the current revision of your file.

Mithras answered 20/8, 2009 at 4:54 Comment(1)
The really irritaing thing about this is that the File Version entry in the Assembly.cs doesn't accept .* like the Assembly Version does.Chacha
B
3

Installers will use AssemblyFileVersion to determine whether to overwrite a file based on version.

It's important to note that changing the AssemblyVersion for an assembly that implements serialization has some serious consequences when trying to deserialize from a previous version.

Beefy answered 20/8, 2009 at 12:38 Comment(0)
A
3

I am not an expert, and I may not be referencing an expert, but from what I have understood, broadly speaking the AssemblyVersion is about the 'interface' -> what the assembly does, backward compatibility etc. And the AssemblyFileVersion is more to do with implementation, which build etc.

Use AssemblyVersion attribute to specify "Last Compatible-To" version and AssemblyFileVersion attribute to specify the build version.”

-> http://www.shitalshah.com/blog/IsJeffRichterScrewingUpTheNetVersioning.aspx

//Oh, and another thing.

There are certain circumstances (about which I'm not too clear, as I've only heard about them but not actually experienced them) where if you try to update an application with dll's in the GAC, old versions of dlls won't be overwritten by new versions with the same Assembly Version number, unless the File Version has changed. (Is that sentence complicated enough? It's late here...)

Acaroid answered 28/9, 2009 at 13:32 Comment(0)
C
2

AssemblyFileVersion is used to set the version info in the Win32 resource in your binary, the one you see if you open the properties window for the file in Explorer.

Catalase answered 20/8, 2009 at 4:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.