mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System.Reflection;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Microsoft.CommandPalette.UI.ViewModels.Helpers;
|
|
|
|
public static class BuildInfo
|
|
{
|
|
#if DEBUG
|
|
public const string Configuration = "Debug";
|
|
#else
|
|
public const string Configuration = "Release";
|
|
#endif
|
|
|
|
// Runtime AOT detection
|
|
public static bool IsNativeAot => !RuntimeFeature.IsDynamicCodeSupported;
|
|
|
|
// From assembly metadata (build-time values)
|
|
public static bool PublishTrimmed => GetBoolMetadata("PublishTrimmed", false);
|
|
|
|
// From assembly metadata (build-time values)
|
|
public static bool PublishAot => GetBoolMetadata("PublishAot", false);
|
|
|
|
public static bool IsCiBuild => GetBoolMetadata("CIBuild", false);
|
|
|
|
private static string? GetMetadata(string key) =>
|
|
Assembly.GetExecutingAssembly()
|
|
.GetCustomAttributes<AssemblyMetadataAttribute>()
|
|
.FirstOrDefault(a => a.Key == key)?.Value;
|
|
|
|
private static bool GetBoolMetadata(string key, bool defaultValue) =>
|
|
bool.TryParse(GetMetadata(key), out var result) ? result : defaultValue;
|
|
}
|