views:

576

answers:

5

Hello,

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,

+7  A: 

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.

Scott Dorman
I am not using it. So perfectly safe just to comment it out?
robUK
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).
Russell
It can also help prevent dependency issues at run-time, as your project wont build if a dependency has the incorrect file version.
Russell
@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.
Scott Dorman
@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.
Scott Dorman
+2  A: 

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.

RRUZ
+1  A: 

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.

Francis B.
The really irritaing thing about this is that the File Version entry in the Assembly.cs doesn't accept .* like the Assembly Version does.
AnthonyWJones
+2  A: 

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.

C-Pound Guru
+1  A: 

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...)

Benjol