Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set file version comment

Tags:

c#

.net

Where can I set the file version comments..?

We can get it by

FileVersionInfo fv = 
System.Diagnostics.FileVersionInfo.GetVersionInfo(
                   Assembly.GetExecutingAssembly().Location);
var comment = fv.Comments;

Then how can I set it so that I can show the same somewhere..

like image 956
Sayyid Sadik Avatar asked Apr 24 '26 18:04

Sayyid Sadik


2 Answers

For .NET Assemblies you can set the File Version Comments using the AssemblyDescriptionAttribute, which you usually put in the AssemblyInfo.cs file in your project when using Visual Studio.

[assembly: AssemblyDescription("The assembly does xxx by yyy")]

For other types of executables the file version is set using a resource in the file.

The different assembly level File Version attributes maps as follows:

  • FileVersionInfo.Comments = AssemblyDescription
  • FileVersionInfo.CompanyName = AssemblyCompany
  • FileVersionInfo.FileDescription = AssemblyTitle
  • FileVersionInfo.FileVersion = AssemblyFileVersion
  • FileVersionInfo.LegalCopyright = AssemblyCopyright
  • FileVersionInfo.LegalTrademarks = AssemblyTrademark
  • FileVersionInfo.ProductName = AssemblyProduct
  • FileVersionInfo.ProductVersion = AssemblyInformationalVersion
like image 57
PHeiberg Avatar answered Apr 26 '26 08:04

PHeiberg


Nowadays in .Net 6

you can set comments in*.csproj

<Description>My Comment</Description>

And get

public static string GetComments()
{
    var fileName = Assembly.GetEntryAssembly()?.Location;
    if (fileName == null) return String.Empty;
    var versionInfo = FileVersionInfo.GetVersionInfo(fileName);
    return versionInfo?.Comments ?? String.Empty; 
}
like image 28
LWS Avatar answered Apr 26 '26 07:04

LWS