diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs index 4ece931574..9f3100ffa3 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs @@ -1,8 +1,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using System; -using System.Reflection; using Tgstation.Server.Host.Components.Interop.Converters; +using Tgstation.Server.Host.Properties; namespace Tgstation.Server.Host.Components.Interop { @@ -34,11 +34,7 @@ namespace Tgstation.Server.Host.Components.Interop /// /// The DMAPI being used. /// - public static readonly Version Version = Version.Parse( - Assembly - .GetExecutingAssembly() - .GetCustomAttribute() - .RawDMApiVersion); + public static readonly Version Version = Version.Parse(MasterVersionsAttribute.Instance.RawDMApiVersion); /// /// for use when communicating with the DMAPI. diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiVersionAtrribute.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiVersionAtrribute.cs deleted file mode 100644 index be4a05a0c3..0000000000 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiVersionAtrribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace Tgstation.Server.Host.Components.Interop -{ - /// - /// Attribute for bringing in the from MSBuild. - /// - [AttributeUsage(AttributeTargets.Assembly)] - sealed class DMApiVersionAtrribute : Attribute - { - /// - /// The string of the DMAPI version built. - /// - public string RawDMApiVersion { get; } - - /// - /// Initializes a new instance of the . - /// - /// The value of . - public DMApiVersionAtrribute(string rawDMApiVersion) - { - RawDMApiVersion = rawDMApiVersion ?? throw new ArgumentNullException(nameof(rawDMApiVersion)); - } - } -} diff --git a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs index a806ea56f7..e58c8d036e 100644 --- a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System; using Tgstation.Server.Api.Models.Internal; +using Tgstation.Server.Host.Properties; using Tgstation.Server.Host.Setup; namespace Tgstation.Server.Host.Configuration @@ -25,7 +26,7 @@ namespace Tgstation.Server.Host.Configuration /// /// The current . /// - public static readonly Version CurrentConfigVersion = new Version(2, 1, 0); + public static readonly Version CurrentConfigVersion = Version.Parse(MasterVersionsAttribute.Instance.RawConfigurationVersion); /// /// The default value for . diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index e8c6f11a48..b344c2a85d 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -35,6 +35,7 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; +using Tgstation.Server.Host.Properties; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Setup; using Tgstation.Server.Host.System; @@ -433,6 +434,11 @@ namespace Tgstation.Server.Host.Core else logger.LogDebug("Web control panel disabled!"); + var masterVersionsAttribute = MasterVersionsAttribute.Instance; + logger.LogTrace("Configuration version: {0}", masterVersionsAttribute.RawConfigurationVersion); + logger.LogTrace("DMAPI version: {0}", masterVersionsAttribute.RawDMApiVersion); + logger.LogTrace("Web control panel version: {0}", masterVersionsAttribute.RawControlPanelVersion); + logger.LogDebug("Starting hosting..."); // authenticate JWT tokens using our security pipeline if present, returns 401 if bad diff --git a/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs b/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs new file mode 100644 index 0000000000..20cc04786c --- /dev/null +++ b/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs @@ -0,0 +1,50 @@ +using System; +using System.Reflection; + +namespace Tgstation.Server.Host.Properties +{ + /// + /// Attribute for bringing in the master versions list from MSBuild that aren't embedded into assemblies by default. + /// + [AttributeUsage(AttributeTargets.Assembly)] + sealed class MasterVersionsAttribute : Attribute + { + /// + /// Return the 's instance of the . + /// + public static MasterVersionsAttribute Instance => Assembly + .GetExecutingAssembly() + .GetCustomAttribute(); + + /// + /// The of the version built. + /// + public string RawConfigurationVersion { get; } + + /// + /// The of the DMAPI version built. + /// + public string RawDMApiVersion { get; } + + /// + /// The of the control panel version built. + /// + public string RawControlPanelVersion { get; } + + /// + /// Initializes a new instance of the . + /// + /// The value of . + /// The value of . + /// The value of . + public MasterVersionsAttribute( + string rawConfigurationVersion, + string rawDMApiVersion, + string rawControlPanelVersion) + { + RawConfigurationVersion = rawConfigurationVersion ?? throw new ArgumentNullException(nameof(rawConfigurationVersion)); + RawDMApiVersion = rawDMApiVersion ?? throw new ArgumentNullException(nameof(rawDMApiVersion)); + RawControlPanelVersion = rawControlPanelVersion ?? throw new ArgumentNullException(nameof(rawControlPanelVersion)); + } + } +} diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index bee26f447e..351989b019 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -41,14 +41,16 @@ - + - - <_Parameter1>$(TgsDmapiVersion) + + <_Parameter1>$(TgsConfigVersion) + <_Parameter2>$(TgsDmapiVersion) + <_Parameter3>$(TgsControlPanelVersion) - +