3

It's quite easy to read some metadata of an assembly, just load the Assembly and then get the custom attributes, for example:

Assembly assembly = Assembly.GetExecutingAssembly();
AssemblyTitleAttribute? attribute = assembly.GetCustomAttribute<AssemblyTitleAttribute>();
string? title = attribute?.Title;

You can replace the AssemblyTitleAttribute by a few others like Copyright, Trademark, Description, Version but I'm unable to find something for the Authors (this metadata can be set at the same location than the other, on the package Tab of the project's solution).

enter image description here

Any idea why this attribute is missing and how it would be possible to read it's value? (I'm using dotnet standard 2.1)

Bidou
  • 7,378
  • 9
  • 47
  • 70

1 Answers1

4

There is No assembly Attribute for Authors neither can it be queried via Reflection or Shell32

Here's a list of AssembyInfo attributes and Authors is not one of them

As per the updated screen shot in the question, you are referring to Project>Properties>Package view and the fields you see here are a mixture of AssemblyInfo & Nuget Metadata Properties

Properties such as Copyright and Description are common for both

Where as properties such as PackageId, Authors, PackageVersion are Nuget Metadata properties which cannot be queried from the assembly.
Nuget Metadata Properties are a list of properties that are used as inputs to the packing process

Why do we even have Authors as a field in Project>Properties>Package ?

  • It is so that it can be references by nuget.org for displaying author's name

From Microsoft Doc

Authors: A semicolon-separated list of packages authors, matching the profile names on nuget.org. These are displayed in the NuGet Gallery on nuget.org and are used to cross-reference packages by the same authors.

References:

Nuget MetaData Properties

Setting Extended Properties:

Custom Assembly Attributes

Clint
  • 6,011
  • 1
  • 21
  • 28
  • 2
    Ok, to be honest I don't find this mix between Nuget Package and assembly a wise idea... It's a bit confusing! – Bidou Feb 10 '20 at 05:33