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).
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)
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
?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With