mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 16:39:21 +01:00
Improve master version handling
This commit is contained in:
@@ -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
|
||||
/// <summary>
|
||||
/// The DMAPI <see cref="Version"/> being used.
|
||||
/// </summary>
|
||||
public static readonly Version Version = Version.Parse(
|
||||
Assembly
|
||||
.GetExecutingAssembly()
|
||||
.GetCustomAttribute<DMApiVersionAtrribute>()
|
||||
.RawDMApiVersion);
|
||||
public static readonly Version Version = Version.Parse(MasterVersionsAttribute.Instance.RawDMApiVersion);
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="JsonSerializerSettings"/> for use when communicating with the DMAPI.
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for bringing in the <see cref="DMApiConstants.Version"/> from MSBuild.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Assembly)]
|
||||
sealed class DMApiVersionAtrribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Version"/> string of the DMAPI version built.
|
||||
/// </summary>
|
||||
public string RawDMApiVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DMApiVersionAtrribute"/> <see langword="class"/>.
|
||||
/// </summary>
|
||||
/// <param name="rawDMApiVersion">The value of <see cref="RawDMApiVersion"/>.</param>
|
||||
public DMApiVersionAtrribute(string rawDMApiVersion)
|
||||
{
|
||||
RawDMApiVersion = rawDMApiVersion ?? throw new ArgumentNullException(nameof(rawDMApiVersion));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// The current <see cref="ConfigVersion"/>.
|
||||
/// </summary>
|
||||
public static readonly Version CurrentConfigVersion = new Version(2, 1, 0);
|
||||
public static readonly Version CurrentConfigVersion = Version.Parse(MasterVersionsAttribute.Instance.RawConfigurationVersion);
|
||||
|
||||
/// <summary>
|
||||
/// The default value for <see cref="ServerInformation.MinimumPasswordLength"/>.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Tgstation.Server.Host.Properties
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for bringing in the master versions list from MSBuild that aren't embedded into assemblies by default.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Assembly)]
|
||||
sealed class MasterVersionsAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Return the <see cref="Assembly"/>'s instance of the <see cref="MasterVersionsAttribute"/>.
|
||||
/// </summary>
|
||||
public static MasterVersionsAttribute Instance => Assembly
|
||||
.GetExecutingAssembly()
|
||||
.GetCustomAttribute<MasterVersionsAttribute>();
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Version"/> <see cref="string"/> of the <see cref="Configuration"/> version built.
|
||||
/// </summary>
|
||||
public string RawConfigurationVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Version"/> <see cref="string"/> of the DMAPI version built.
|
||||
/// </summary>
|
||||
public string RawDMApiVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Version"/> <see cref="string"/> of the control panel version built.
|
||||
/// </summary>
|
||||
public string RawControlPanelVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MasterVersionsAttribute"/> <see langword="class"/>.
|
||||
/// </summary>
|
||||
/// <param name="rawConfigurationVersion">The value of <see cref="RawConfigurationVersion"/>.</param>
|
||||
/// <param name="rawDMApiVersion">The value of <see cref="RawDMApiVersion"/>.</param>
|
||||
/// <param name="rawControlPanelVersion">The value of <see cref="RawControlPanelVersion"/>.</param>
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,14 +41,16 @@
|
||||
<RemoveDir Directories="wwwroot" />
|
||||
</Target>
|
||||
|
||||
<Target Name="GenerateBuildVersionsAttribute" BeforeTargets="CoreCompile">
|
||||
<Target Name="ApplyMasterVersionsAttribute" BeforeTargets="CoreCompile">
|
||||
<ItemGroup>
|
||||
<AssemblyAttributes Include="Tgstation.Server.Host.Components.Interop.DMApiVersionAtrribute">
|
||||
<_Parameter1>$(TgsDmapiVersion)</_Parameter1>
|
||||
<AssemblyAttributes Include="Tgstation.Server.Host.Properties.MasterVersionsAttribute">
|
||||
<_Parameter1>$(TgsConfigVersion)</_Parameter1>
|
||||
<_Parameter2>$(TgsDmapiVersion)</_Parameter2>
|
||||
<_Parameter3>$(TgsControlPanelVersion)</_Parameter3>
|
||||
</AssemblyAttributes>
|
||||
</ItemGroup>
|
||||
|
||||
<WriteCodeFragment AssemblyAttributes="@(AssemblyAttributes)" Language="C#" OutputDirectory="$(IntermediateOutputPath)" OutputFile="DMApiVersion.cs">
|
||||
<WriteCodeFragment AssemblyAttributes="@(AssemblyAttributes)" Language="C#" OutputDirectory="$(IntermediateOutputPath)" OutputFile="MasterVersionsAssemblyInfo.cs">
|
||||
<Output TaskParameter="OutputFile" ItemName="Compile" />
|
||||
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
|
||||
</WriteCodeFragment>
|
||||
|
||||
Reference in New Issue
Block a user