As the title suggests I need to assign an application a custom file and/or product version by building a project from Visual Studio.
I know you can assign a build number from an application publish but I am not publishing these applications, I am simply building "release" files.
Is there a way within Visual Studio to specify these file versions before I build the application?
Thanks in advance!
Is there a way within Visual Studio to specify these file versions before I build the application?
Yes, you can specify File/Product version by AssemblyInfo.cs
before you build the application.
First, the File version looks for the attribute AssemblyFileVersion
in the AssemblyInfo.cs
file. So you can specify the File version by setting the value AssemblyFileVersion
. I change the AssemblyFileVersion
value from 1.0.0.0
to 2.0.0.0
:
[assembly: AssemblyFileVersion("2.0.0.0")]
Second, ProductVersion first looks to see if the assembly containing the main
executable has the AssemblyInformationalVersion
attribute on it. If this
attribute exists, it is used for Product Version.
If this attribute does not exist, both properties use the AssemblyFileVersion
instead.
So, in your project, open the AssemblyInfo.cs file. In this file, I added a line like this:
[assembly: AssemblyInformationalVersion("4.0.0.0")]
Then after build is complete. The file version is 2.0.0.0
and the product version is 4.0.0.0
.