Skip to content

Commit

Permalink
Read FileVersion from assembly metadata.
Browse files Browse the repository at this point in the history
This works even when the assembly was not loaded directly from a file.
  • Loading branch information
mbergin committed Mar 23, 2021
1 parent 72da117 commit ce13790
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/OpenTelemetry/Resources/ResourceBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;

namespace OpenTelemetry.Resources
{
Expand Down Expand Up @@ -126,7 +127,7 @@ private static string GetFileVersion()
{
try
{
return FileVersionInfo.GetVersionInfo(typeof(Resource).Assembly.Location).FileVersion;
return typeof(Resource).Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version ?? string.Empty;
}
catch (Exception)
{
Expand Down

0 comments on commit ce13790

Please sign in to comment.