diff --git a/backend/src/api/NetworkResurrector.Api.Application/Queries/GetSystemVersion.cs b/backend/src/api/NetworkResurrector.Api.Application/Queries/GetSystemVersion.cs index 1bf9ed9..ccac314 100644 --- a/backend/src/api/NetworkResurrector.Api.Application/Queries/GetSystemVersion.cs +++ b/backend/src/api/NetworkResurrector.Api.Application/Queries/GetSystemVersion.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging; using NetworkResurrector.Server.Wrapper.Services; using System; using System.IO; +using System.Linq; using System.Reflection; using System.Threading; using System.Threading.Tasks; @@ -35,12 +36,12 @@ namespace NetworkResurrector.Api.Application.Queries public async Task Handle(Query request, CancellationToken cancellationToken) { var apiVersion = GetApiVersion(); - var serverVersion = await GetServerVersion(); + var (version, lastUpdateDate) = await GetServerVersion(); var result = new Model { Api = apiVersion, - Server = serverVersion + Server = new ServiceVersion(FormatVersion(version), lastUpdateDate) }; return result; @@ -52,7 +53,7 @@ namespace NetworkResurrector.Api.Application.Queries var appDate = Environment.GetEnvironmentVariable("APP_DATE"); if (string.IsNullOrEmpty(version)) - version = Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion; + version = Assembly.GetEntryAssembly().GetName().Version.ToString(); if (!DateTime.TryParse(appDate, out var lastReleaseDate)) { @@ -60,7 +61,7 @@ namespace NetworkResurrector.Api.Application.Queries lastReleaseDate = File.GetLastWriteTime(location); } - var result = new ServiceVersion(version, lastReleaseDate); + var result = new ServiceVersion(FormatVersion(version), lastReleaseDate); return result; } @@ -77,6 +78,17 @@ namespace NetworkResurrector.Api.Application.Queries } return new ServiceVersion("0.0.0", DateTime.MinValue); } + + private string FormatVersion(string version) + { + if (string.IsNullOrEmpty(version)) + return string.Empty; + var parts = version.Split('.'); + if (parts.Length < 3) + return version; + var shortVersion = string.Join('.', parts.Take(3)); + return shortVersion; + } } } } diff --git a/backend/src/server/NetworkResurrector.Server.Application/Queries/GetServiceVersion.cs b/backend/src/server/NetworkResurrector.Server.Application/Queries/GetServiceVersion.cs index 304ad29..3dad5c2 100644 --- a/backend/src/server/NetworkResurrector.Server.Application/Queries/GetServiceVersion.cs +++ b/backend/src/server/NetworkResurrector.Server.Application/Queries/GetServiceVersion.cs @@ -24,7 +24,7 @@ namespace NetworkResurrector.Server.Application.Queries var appDate = Environment.GetEnvironmentVariable("APP_DATE"); if (string.IsNullOrEmpty(version)) - version = Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion; + version = Assembly.GetEntryAssembly().GetName().Version.ToString(); if (!DateTime.TryParse(appDate, out var lastReleaseDate)) {