Use more robust version code

This commit is contained in:
Matt Nadareski
2025-04-07 09:55:08 -04:00
parent 6c59efa63b
commit 8d1d192f11

View File

@@ -14,7 +14,25 @@ namespace SabreTools.Core
/// <summary>
/// The current toolset version to be used by all child applications
/// </summary>
public readonly static string? Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
public static string? Version
{
get
{
try
{
var assembly = Assembly.GetEntryAssembly();
if (assembly == null)
return null;
var assemblyVersion = Attribute.GetCustomAttribute(assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
return assemblyVersion?.InformationalVersion;
}
catch (Exception ex)
{
return ex.ToString();
}
}
}
#if NET452_OR_GREATER || NETCOREAPP
/// <summary>