3

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

horgh
  • 17,918
  • 22
  • 68
  • 123
Sayyid Sadik
  • 63
  • 1
  • 6

3 Answers3

9

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
PHeiberg
  • 29,411
  • 6
  • 59
  • 81
  • You're welcome. Feel free to accept the answer you think is most helpful, by marking it as "accepted". – PHeiberg Oct 04 '12 at 11:06
1

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; 
}
LWS
  • 329
  • 3
  • 15
0

To set this value, you can edit the AssemblyInfo.cs file of your project.

This line is what you are looking for:

[assembly: AssemblyDescription("This is the comment")]
Yannick Blondeau
  • 9,465
  • 8
  • 52
  • 74