diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index e384c89d13..3ed0361ef0 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -209,6 +209,7 @@ changecursor CHILDACTIVATE CHILDWINDOW CHOOSEFONT +CIBUILD cidl CIELCh cim diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/BuildInfo.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/BuildInfo.cs index 7f129d8b06..a276d38f47 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/BuildInfo.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/BuildInfo.cs @@ -2,7 +2,6 @@ // 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.CmdPal.UI.Helpers; @@ -18,19 +17,41 @@ internal static class BuildInfo // Runtime AOT detection public static bool IsNativeAot => !RuntimeFeature.IsDynamicCodeSupported; - // From assembly metadata (build-time values) - public static bool PublishTrimmed => GetBoolMetadata("PublishTrimmed", false); + // build-time values + public static bool PublishTrimmed + { + get + { +#if BUILD_INFO_PUBLISH_TRIMMED + return true; +#else + return false; +#endif + } + } - // From assembly metadata (build-time values) - public static bool PublishAot => GetBoolMetadata("PublishAot", false); + // build-time values + public static bool PublishAot + { + get + { +#if BUILD_INFO_PUBLISH_AOT + return true; +#else + return false; +#endif + } + } - public static bool IsCiBuild => GetBoolMetadata("CIBuild", false); - - private static string? GetMetadata(string key) => - Assembly.GetExecutingAssembly() - .GetCustomAttributes() - .FirstOrDefault(a => a.Key == key)?.Value; - - private static bool GetBoolMetadata(string key, bool defaultValue) => - bool.TryParse(GetMetadata(key), out var result) ? result : defaultValue; + public static bool IsCiBuild + { + get + { +#if BUILD_INFO_CIBUILD + return true; +#else + return false; +#endif + } + } } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj index 79ce3ff5ee..65174cb0b9 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj @@ -53,7 +53,7 @@ - DISABLE_XAML_GENERATED_MAIN + $(DefineConstants);DISABLE_XAML_GENERATED_MAIN @@ -291,24 +291,15 @@ - - - - <_Parameter1>PublishTrimmed - <_Parameter2>$(PublishTrimmed) - - - <_Parameter1>PublishAot - <_Parameter2>$(PublishAot) - - - <_Parameter1>CIBuild - <_Parameter2>$(CIBuild) - - - <_Parameter1>CommandPaletteBranding - <_Parameter2>$(CommandPaletteBranding) - - + + + $(DefineConstants);BUILD_INFO_PUBLISH_AOT + + + $(DefineConstants);BUILD_INFO_PUBLISH_TRIMMED + + + $(DefineConstants);BUILD_INFO_CIBUILD +