[backend] Add codename to assembly metadata

This commit is contained in:
Laura Hausmann 2024-05-24 22:41:43 +02:00
parent 46d5fdc1af
commit 9eb5710e84
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 19 additions and 5 deletions

View file

@ -16,15 +16,25 @@ public sealed class Config
public sealed class InstanceSection public sealed class InstanceSection
{ {
public readonly string Version; public readonly string Version;
public readonly string Codename;
public InstanceSection() public InstanceSection()
{ {
var attributes = Assembly.GetEntryAssembly()!
.GetCustomAttributes()
.ToList();
// Get codename from assembly
Codename = attributes
.OfType<AssemblyMetadataAttribute>()
.FirstOrDefault(p => p.Key == "codename")
?.Value ??
"unknown";
// Get version information from assembly // Get version information from assembly
var version = Assembly.GetEntryAssembly()! var version = attributes.OfType<AssemblyInformationalVersionAttribute>()
.GetCustomAttributes() .First()
.OfType<AssemblyInformationalVersionAttribute>() .InformationalVersion;
.First()
.InformationalVersion;
// If we have a git revision, limit it to 10 characters // If we have a git revision, limit it to 10 characters
if (version.Split('+') is { Length: 2 } split) if (version.Split('+') is { Length: 2 } split)

View file

@ -13,6 +13,10 @@
<GarbageCollectionAdaptationMode>1</GarbageCollectionAdaptationMode> <GarbageCollectionAdaptationMode>1</GarbageCollectionAdaptationMode>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<AssemblyMetadata Include="codename" Value="alpha" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<BlazorWebAssemblyOmitDebugProxyOutput>true</BlazorWebAssemblyOmitDebugProxyOutput> <BlazorWebAssemblyOmitDebugProxyOutput>true</BlazorWebAssemblyOmitDebugProxyOutput>
<PreserveCompilationContext>false</PreserveCompilationContext> <PreserveCompilationContext>false</PreserveCompilationContext>