Skip to content

Commit 3639e42

Browse files
Use assembly informational version
1 parent 379d53f commit 3639e42

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/Umbraco.AuthorizedServices/Constants.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Diagnostics;
1+
using System.Reflection;
2+
using Umbraco.Cms.Core.Semver;
3+
using Umbraco.Extensions;
24

35
namespace Umbraco.AuthorizedServices;
46

@@ -10,7 +12,28 @@ public static class Constants
1012

1113
public const string Separator = "-";
1214

13-
public static readonly string InformationalVersion = FileVersionInfo.GetVersionInfo(typeof(Constants).Assembly.Location).ProductVersion!;
15+
public static readonly string InformationalVersion = GetInformationalVersion();
16+
17+
private static string GetInformationalVersion()
18+
{
19+
Assembly assembly = typeof(Constants).Assembly;
20+
AssemblyInformationalVersionAttribute? assemblyInformationalVersionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
21+
if (assemblyInformationalVersionAttribute is not null &&
22+
SemVersion.TryParse(assemblyInformationalVersionAttribute.InformationalVersion, out SemVersion? semVersion))
23+
{
24+
return semVersion!.ToSemanticStringWithoutBuild();
25+
}
26+
else
27+
{
28+
AssemblyName assemblyName = assembly.GetName();
29+
if (assemblyName.Version is not null)
30+
{
31+
return assemblyName.Version.ToString(3);
32+
}
33+
}
34+
35+
return string.Empty;
36+
}
1437

1538
public static class Trees
1639
{

0 commit comments

Comments
 (0)