Core - Embed PluginApiVersion into the assembly metadata

This commit is contained in:
Diogo Trindade authored and RobertBeekman committed 2022-09-30 23:42:15 +02:00
1 parent 22268fc945
commit 3f1eaeda29
2 files changed
+8 -1

No files matched your search

+5
View File
@@ -13,6 +13,11 @@
<PluginApiVersion>1</PluginApiVersion>
</PropertyGroup>
<ItemGroup>
<!--Used to embed the above PluginApiVersion property into the assembly as metadata-->
<AssemblyMetadata Include="PluginApiVersion" Value="$(PluginApiVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj"/>
<ProjectReference Condition="'$(BuildingNuget)' == 'True'" Update="..\Artemis.Storage\Artemis.Storage.csproj" PrivateAssets="All"/>
+3 -1
View File
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
using Artemis.Core.JsonConverters;
using Artemis.Core.Services;
@@ -61,7 +62,8 @@ public static class Constants
/// <summary>
/// The current API version for plugins
/// </summary>
public static readonly int PluginApiVersion = CoreAssembly.GetName().Version.Major;
public static readonly int PluginApiVersion = int.Parse(CoreAssembly.GetCustomAttributes<AssemblyMetadataAttribute>()
.First(a => a.Key == "PluginApiVersion").Value);
/// <summary>
/// The plugin info used by core components of Artemis