How to obtain build configuration at runtime?

There is AssemblyConfigurationAttribute in .NET. You can use it in order to get name of build configuration

var assemblyConfigurationAttribute = typeof(CLASS_NAME).Assembly.GetCustomAttribute<AssemblyConfigurationAttribute>();
var buildConfigurationName = assemblyConfigurationAttribute?.Configuration;

Leave a Comment